RoboTek Arduino Level 1
RoboTek Arduino Level 1
INTRODUCTION TO ARDUINO
LEVEL 1
MODULE 1
Target Outcomes
Materials
- plastic bottle
- rubber band
- dynamo
- popsicle stick
- paper
- plastic cups
Session 1: How do robots perform tasks?
Assessment Task 1a
Assessment Task 1b
Key Discussion
Characteristics of Robotics
1. Sensing – to be able to sense its
surroundings
2. Movement – to be able to move around its
environment
3. Energy – to be able to have power
4. Intelligence – a robot needs some kind of
“smarts”
Session 1: How do robots perform tasks?
Key Discussion
Ideal task for robots
1. Dangerous
2. Repetitive
3. High Precision
Robots are usually applied four D’s:
1. Dirty
2. Dangerous
3. Dull and
4. Difficult for human to perform
Session 1: How do robots perform tasks?
Practical Activity
Subject Integration
1. Science- describe some properties of metals
and non-metals such as its invulnerability.
2. English – Discover literature as a means of
connecting to a significant past.
SESSION 2: HOW DO ROBOTS
UNDERSTAND INSTRUCTIONS?
MICROCONTROLLER
Session 2: How do robots understand instructions?
Target Outcomes
Materials
- Arduino Microcontrollers
Session 2: How do robots understand instructions?
MCU
Session 2: How do robots understand instructions?
Key Discussion
Assessment task 1b
The students will label
each part of an actual
Arduino as the teacher
discussed the parts one
by one based from the
picture in the students
handouts.
Session 2: How do robots understand instructions?
Key Discussion
1. Power IN (Barrel Jack)
Key Discussion
4. LED (TX:
Transmitting)
5. LED
(Troubleshooting)
Session 2: How do robots understand instructions?
Key Discussion
6. Pins (Digital, Analog,
Ground) - It can be used for
input, output, power and
ground.
Pin 0 – 13
Analog Output Pins / PWM
Pins
Pin ~ 3, ~5, ~6, ~9, ~10 and
~11
7. LED (ON/OFF) - It indicates
if there is a power.
Session 2: How do robots understand instructions?
Key Discussion
8. Reset Button - It manually reset the
Arduino that make your code to
restart.
9. Pins (Analog In, Power In, Ground
Power Out, Reset) - It can be used for
input, output, power and ground.
1.Pin A0 – A5
2. Power Pin
3. Reset
4. +3.3 V
5. 5V
6. Ground
7. VIN (Voltage/Power IN)
Session 2: How do robots understand instructions?
Key Discussion
Specifications
Microcontroller: ATmega328
Operating Voltage: 5V
Input Voltage (Recommended): 7 - 12V
Input Voltage (limits): 6 - 20V
Digital I/O Pins: 14 (of which 6 provide PWM
output)
Analog Input Pins: 6
Session 2: How do robots understand instructions?
Key Discussion
Assessment task 2
Answer the questions based on the set up.
1. What if Power In (USB port) is not detected in
the Arduino IDE?
2. Where do you think is the problem if LED
(ON/OFF) don’t have light?
3. What if Power In (barrel jack) will be
connected to 15V?
Subject Integration
Extension cord
Breadboard
Session 3: How breadboard and wiring connection works?
Assessment Task 1a
1.What’s
this?
2. What is
its use?
Session 3: How breadboard and wiring connection works?
Key Discussion
BREADBOARD – is used to
create circuits and connect
different sensors and
actuators to the Arduino
board it also refers to a
solderless breadboard.
BREADBOARD
Session 3: How breadboard and wiring connection works?
Key Discussion
Key Discussion
Assessment Task 1b
Observe the picture Power Rails
and identify the parts
of an actual
breadboard.
Key Discussion
1– Serial connection
from positive 1 to
30 is used to
connect the
horizontal pins
which is called
power rails.
Session 3: How breadboard and wiring connection works?
Key Discussion
2– Serial
connection from
A1, B1, C1, D1
and E1 is used to
connect the
vertical pins.
Session 3: How breadboard and wiring connection works?
Key Discussion
Types of Circuit
Connection
Target outcomes:
Fig. 2
Fig. 3
Path
Source
Fig.1 Schematic Wiring Fig. 2 Breadboard Wiring
Key Discussion
4.
Session 4: How LED works with the breadboard and MCU?
Light Emitting
Diode (LED)
Session 4: How LED works with the breadboard and MCU?
Assessment task 1
Label each
part of an
actual LED
from the
picture.
Session 4: How LED works with the breadboard and MCU?
Key Discussion
Key Discussion
Key Discussion
Key Discussion
Assessment Task 2b
1.
2. Essay:
3. Explain the use of:
4. 11-15. breadboard
6.
16-20.circuit
5.
7. connections
21-25. LED.
8.
9. 10.
Subject Integration
Materials
Serial Monitor Displays serial data being sent from the Arduino
Assessment Task 1
__________1. Saves a. hex file that may be kept as archive or sent to the board
using other tools.
__________2. Opens the current sketch folder.
__________3. Adds a library to your sketch by inserting #include statements at the
start of your code.
__________4. Adds a source file to the sketch (it will be copied from its current
location.
__________5. Checks your sketch for errors compiling it; it will report memory
usage for code and variables in the console area.
__________6. Compiles and loads the binary file onto the configured board through
the configured Port.
__________7. This will overwrite the bootloader on the board; you will need to use
Tools > Burn Bootloader to restore it and be able to Upload to USB serial port again.
SESSION 6: HOW TO
MANIPULATE ARDUINO IDE
PARTS, SETTING-UP, SKETCH CODE AND CONDITIONAL CONTROL STRUCTURE
Target outcomes:
Arduino Interface
Development
Environment
Session 6: HOW TO MANIPULATE ARDUINO IDE
Key Discussion
Key Discussion
void setup( ) {
// put your setup code here, to run once:
}
void loop( ) {
// put your main code here, to run repeatedly:
}
SKETCH – SAMPLE CODE
Assessment
SESSION 7: CONDITIONAL CONTROL STRUCTURES
Conditional Control
Structure
Target outcomes:
== is equal to
!= is not equal to
10 void loop()
11 {
12 if(delayTime <= 100){
13 delayTime = 1000;
14 }
15 else{
16 delayTime = delayTime - 100;
17 }
18 digitalWrite(kPinLed, HIGH);
19 delay(delayTime);
20 digitalWrite(kPinLed, LOW);
21 delay(delayTime);
22 }
SESSION 7: CONDITIONAL CONTROL STRUCTURES
Key Discussion
void loop ()
{
int x, y, z;
x = analogRead (JoyStick_X);
y = analogRead (JoyStick_Y);
if (x == 1023){
digitalWrite(led1, HIGH);
}
else if (x == 0){
digitalWrite(led2, HIGH);
}
else if (y == 1023){
digitalWrite(led3, HIGH);
}
else if (y == 0){
digitalWrite(led4, HIGH);
}
else {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
}
SESSION 7: CONDITIONAL CONTROL STRUCTURES
COMBINATIONS
Operator Example Meaning
&& (A < 10) && (B > 5) logical AND (return TRUE if condition A AND condition B are true,
otherwise return FALSE.)
!! (A < 10) logical NOT (return TRUE if condition A is false, otherwise return
FALSE.)
SESSION 7: CONDITIONAL CONTROL STRUCTURES
For example:
void loop()
{
ledState = !ledState;
digitalWrite(kPinLed, ledState);
delay(1000);
}
SESSION 7: CONDITIONAL CONTROL STRUCTURES
8 void loop()
9 {
11 digitalWrite(kPinLed, HIGH);
12 delay(200);
13 digitalWrite(kPinLed, LOW);
14 delay(200);
15 }
16 delay(1000); // 1 second
17 }
SESSION 7: CONDITIONAL CONTROL STRUCTURES
Practical Activity
Assessment Task 2
1.
10 void loop()
11 {
2.
8 void loop()
9 {
11 digitalWrite(kPinLed, HIGH);
12 delay(200);
13 digitalWrite(kPinLed, LOW);
14 delay(200);
15 }
16 delay(1000); // 1 second
17 }
SESSION 7: CONDITIONAL CONTROL STRUCTURES
3.
void loop ()
{
int x, y, z;
x = analogRead (JoyStick_X);
y = analogRead (JoyStick_Y);
if (x == 1023){
digitalWrite(led1, HIGH);
}
else if (x == 0){
digitalWrite(led2, HIGH);
}
else if (y == 1023){
digitalWrite(led3, HIGH);
}
else if (y == 0){
digitalWrite(led4, HIGH);
}
else {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
}
SESSION 7: CONDITIONAL CONTROL STRUCTURES
4.
10 void loop()
11 {
12 while(delayTime > 0){ // while delayTime is greater than 0
13 digitalWrite(kPinLed, HIGH);
14 delay(delayTime);
15 digitalWrite(kPinLed, LOW);
16 delay(delayTime);
17 delayTime = delayTime - 100;
18 }
19 while(delayTime < 1000){ // while delayTime is less than !! "" 1000
5.
10 void loop()
11 {
12 if(delayTime <= 100){
13 delayTime = 1000;
14 }
15 else{
16 delayTime = delayTime - 100;
17 }
18 digitalWrite(kPinLed, HIGH);
19 delay(delayTime);
20 digitalWrite(kPinLed, LOW);
21 delay(delayTime);
22 }
Science - describe the different types of
charging processes
English - Transcode orally and in writing
the information presented in diagrams,
charts, table, graphs, etc.
MODULE 2
1. 2.
3.
4. 5.
1. Always remember
and make sure that
your hands are dry
(use working gloves
if necessary).
2. Make sure your
working area are clean.
NO Liquid materials or
Drinks
NO Conductible
material near work
area
3. Make sure
where the
first aid kits
are place.
Assessment
Practical Activity
Target Outcomes
Target outcomes:
Identify the functions of each part to the
wiring connections.
Differentiate Voltage, Resistance, and
Current.
Session 9: HOW DOES ELECTRONIC CIRCUIT
FUNCTION?
Materials
Tissue roll
Session 9: HOW DOES ELECTRONIC CIRCUIT
FUNCTION?
Assessment Task 1
VOLTAGE is the
difference in
charge between
AC DC two points.
Session 9: HOW DOES ELECTRONIC CIRCUIT
FUNCTION?
Practical Activity
Materials
Practical Activity 2
Microcontroller
Practical Activity I
USB Cable
Microcontroller Jumper Wire Practical Activity 3
USB Cable Breadboard Microcontroller
Jumper Wire 2 pcs. 220 USB Cable
Breadboard Resistors
Jumper Wire
1k Resistors 2 pcs. LED (Any color)
Breadboard
LED (Any color)
Assessment 2b 8 pcs. 220 Resistors
Assessment 2a 8 pcs. LED (Any color)
Microcontroller
Microcontroller USB Cable
USB Cable
Jumper Wire
Jumper Wire
Breadboard Breadboard
1 pc. 220 Resistors 3 pcs. 220 Resistors
1 pc. LED (Any color) 1 pc. LED (Red, Yellow, Green)
Session 10: HOW DOES A RESISTOR WORK?
Assessment Task 1
What happen to the gum if the jar is:
1.Slightly open or with small hole?
2.Widely open?
3.It is close?
Session 10: HOW DOES A RESISTOR WORK?
V
____
R =
I
where I is the current in amperes, V the voltage in volts and R
the resistance in ohms.
Session 10: HOW DOES A RESISTOR WORK?
CIRCUIT CONNECTION
AND PROGRAMMING
USING ARDUINO IDE
Session 11: Resistance Value with Arduino
Practical Activity I int LED = 2;
/* int means integer, LED is a variable that will be used to
represent the device connected on the microcontroller and
MATERIALS assigning 2 as the value for pin 2*/
void loop( ) {
digitalWrite(LED, HIGH);
/* digitalWrite ( ) is the function in controlling digital device,
inside the parenthesis ( ) are the pin that needs to be controlled
and it can be set either HIGH or LOW */
delay(3000);
/* delay ( ) is the function in controlling digital device, inside the
parenthesis ( ) are the pin that needs to be controlled and it can
be set either HIGH or LOW */
digitalWrite(LED, LOW);
delay(2000);
}
Session 11: Resistance Value with Arduino
Practical Activity 2 int LED1 = 7;
MATERIALS
Microcontroller
int LED2 = 8;
USB Cable void setup( ) {
Jumper Wire
Breadboard pinMode (LED1, OUTPUT); //Pin
2 pcs. 220 Resistors
2 pcs. LED (Any color) 7 is defined as output
pinMode (LED2, OUTPUT);//Pin 8
is defined as output
}
void loop( ) {
Assessment Task 2b
MATERIALS
Microcontroller
USB Cable
Jumper Wire
Breadboard
3 pcs. 220 Resistors
1 pc. LED (Red, Yellow,
Green) TRAFFIC LIGHT
int ledPin1 = 2; // red
int ledPin2 = 4; // yellow //stop
int ledPin3 = 6; // green digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2,LOW);
void setup() { digitalWrite(ledPin3,LOW);
pinMode(ledPin1,OUTPUT); delay(5000);
pinMode(ledPin2,OUTPUT);
pinMode(ledPin3,OUTPUT);
} //ready
void loop() { digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin3,LOW);
delay(3000);
//go
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,LOW);
delay(8000);
//ready
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin3,LOW) ;
delay(3000);
}
Subject Integration
II. Directions: Follow the set up in the schematic diagram and key in the code for this activity.
PROCEDURE
1. You will be given a set of materials.
apple
2. Key in the codes on the Arduino IDE. orange
3. Run the program using serial monitor. banana
grapes
4. Type the following character on the input tab using printIn and without printIn.
26
Philippine Copyright 2018 TechFactors, Inc
MODULE 3
13 Types of Switch
14 Switch Statement
15 Types of Potentiometer
16 How do potentiometers work?
17 Kinds of Buzzer
18 How does a buzzer work?
19 Kind of Segment
20 How does a segment work?
SESSION 13: TYPES OF SWITCH
Session 13: Types of Switch
Target Outcomes
Materials
• Microcontroller
• USB Cable
• Jumper Wire
• Breadboard
• 1 pc. 220 Resistors
• 1 pc. Push Button
Session 13: Types of Switch
Assessment Task 1
Session 13: Types of Switch
SWITCH is an electrical device having
two states, on or off (open or close).
Ideally having zero impedance when
closed and infinite impedance when
open.
Types of switch
Assessment Task
What is the use of a switch in a circuit?
What are the different types of switch?
Draw a schematic diagram of a circuit
with switch. Label and explain its
content.
Identification: Answer the following on the space
provided.
Practical Activity
MATERIALS
•Microcontroller
•USB Cable
•Jumper Wire
•Breadboard
•1 pc. 220 Resistors
•1 pc. Push Button
int pbValue;
/* int means integer, pbValue is a variable that will be used to hold the value that the tact
switch will send to the microcontroller unit */
void setup( ) {
pinMode(2, INPUT);
/* pinMode is a function that prepares ALL the pins used in the microcontroller. 2 is the digital
pin used to connect the tact switch and it’s considered as an INPUT device */
Serial.begin(9600);
// Sets the data rate in bits per second (baud) for serial data transmission
}
void loop( ) {
pbValue = digitalRead(2);
// digitalRead will basically get the data from pin 2 and assign that value to variable pbValue.
Serial.println(pbValue);
// prints over the Serial Monitor the value assigned to pbValue
// Serial.println(“pbValue”); - this code will display the word “pbValue”
}
Subject Integration
Target Outcomes
At the end of this session, the students
are able to:
Define what is potentiometer.
Differentiate the 2 types of
potentiometer.
Materials
Microcontroller
USB Cable
Jumper Wire
Breadboard
1 pc. Potentiometer
Assessment Task 1
Observe the
music coming
out from the
phone.
POTENTIOMETER is a three-terminal
resistor with a sliding or rotating
contact that forms an adjustable voltage
divider.
1. What is a potentiometer?
2. What are the two kinds of
potentiometer?
3. What is the purpose of a potentiometer
in circuit?
SESSION 16:HOW DO POTENTIOMETERS
WORK?
TARGET OUTCOMES:
At the end of this session, the students
are able to:
Identify the correct polarity of a
potentiometer.
Demonstrate the proper wiring in
connecting the circuit to potentiometer.
int varPin = A0;
Practical Activity int val = 0;
MATERIALS void setup() {
Microcontroller // put your setup code here, to run once:
USB Cable Serial.begin(9600);
Jumper Wire Serial.println("Serial connection
Breadboard established..\nAdjust the Potentiometer to see
1 pc. Potentiometer the value change!");
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("Potentiometer Value: ");
val = analogRead(varPin);
Serial.println(val);
}
Acitivity
PROCEDURE
1. You will be given a set of materials.
2. Connect the circuit properly to potentiometer.
3. Key in the given codes in the Arduino IDE.
4. Check your output using your serial monitor.
5. Observe what will be the output display in the serial monitor every time
you turn the knob from le to right and vice versa.
Observation:
______________________________________________
Conclusion:
_______________________________________________
Assessment
Subject Integration
void loop()
{
digitalWrite(buzzer, HIGH); // produce
sound
delay (500);
digitalWrite(buzzer, LOW);
ACTIVE BUZZER ALARM SOUND delay (500);
}
SESSION 18: How does a buzzer work?
Materials
Microcontroller int buzzer=3; // initialize digital IO
USB Cable pin that controls the buzzer
Jumper Wire
Breadboard void setup() {
1 pc. Passive Buzzer
pinMode (buzzer, OUTPUT);
}
void loop() {
tone (buzzer, random (500, 1500);
delay(300); //wait half a second
before changing pitch
}
PASSIVE BUZZER MELODY SOUND
SESSION 18: How does a buzzer work?
void loop() {
analogWrite (buzzer,
random(0,255));
delay(500); //wait half a second
before changing pitch
}
MATERIALS
•Microcontroller
•USB Cable
•Jumper Wire
•Breadboard
•1 pc. Passive Buzzer
SESSION 18: How does a buzzer work?
int buzzerPin = 3; //the buzzer pin attach to
int fre; //set the variable to store the frequency value
void setup()
{
pinMode(buzzerPin, OUTPUT);
}
void loop()
{
for (int i = 200;i <= 800;i++) //frequency loop from 200 to 800
{
tone(buzzerPin,i); //turn the buzzer on
delay(5); //wait for 5 milliseconds
}
delay(4000); //wait for 4 seconds on highest frequency
for(int i = 800;i >= 200;i--)//frequency loop from 800 down to 200
{
tone(buzzerPin,i);
delay(10);
}
}
Subject Integration
Science - explain the functions of circuit
breakers, fuses, earthing, double
insulation, and other safety devices.
Target Outcomes
At the end of this session the students are
able to:
Identify the schematic diagram of a
segment.
Explain the use of a segment.
Assessment Task 1a
Questions:
1. Have you ever tried
watching basketball league?
2. Are you familiar with its
digital scoreboard?
3. How does it looks like?
4. How about the digital
clock? What are their
similarities?
SSD or SEVEN-SEGMENT indicator, is a
form of electronic display device for
displaying decimal numerals that is an
alternative to the more complex dot
matrix displays.
Assessment Task 1b
Find the pin
address by
tracing the
segment.
EX:
0 - ABCDEF
Two Kinds of Segment
ASSESSMENT:
1. 8 7. 2
2. 5 8. 4
3. 3 9. 6
4. 9 10.7
5. 0
6. 1
SESSION 20: HOW DOES A SEGMENT
WORK?
SESSION 20: How does a segment work?
Target Outcomes
At the end of this session the students are
able to:
Learn how to display, code numbers and
operate a segment in basic electronics.
7-Segment Display Segment for All Numbers
It can be seen that to display any single digit number
from 0 to 9 in binary or letters from A to F in
hexadecimal, we would require 7 separate segment
connections plus one additional connection for the
LED’s “common” connection. Also as the segments are
basically a standard light emitting diode, the driving
circuit would need to produce up to 20mA of current
to illuminate each individual segment and to display
the number 8, all 7 segments would need to be lit
resulting a total current of nearly 140mA, (8 x 20mA).
ASSESSMENT:
MATERIALS
Microcontroller
USB Cable
Jumper Wire
Breadboard
1 pc. 7 Segment
int pinA = 2; (pinB,OUTPUT);
int pinB = 3; pinMode
int pinC = 4; (pinC,OUTPUT);
int pinD = 5; pinMode
int pinE = 6; (pinD,OUTPUT);
int pinF = 7; pinMode
int pinG = 8; (pinE,OUTPUT);
void setup() { pinMode
pinMode (pinF,OUTPUT);
(pinA,OUTPUT); pinMode
pinMode (pinG,OUTPUT);
}
void loop() {
//0 //1
digitalWrite (pinA, LOW); digitalWrite (pinA, HIGH);
digitalWrite (pinB, LOW); digitalWrite (pinB, LOW);
digitalWrite (pinC, LOW); digitalWrite (pinC, LOW);
digitalWrite (pinD, LOW); digitalWrite (pinD, HIGH);
digitalWrite (pinE, LOW); digitalWrite (pinE, HIGH);
digitalWrite (pinF, LOW); digitalWrite (pinF, HIGH);
digitalWrite (pinG, HIGH); digitalWrite (pinG, HIGH);
delay(1000); delay(1000);
//2 //4 //6
digitalWrite (pinA, LOW); digitalWrite (pinA, HIGH); digitalWrite (pinA, LOW);
digitalWrite (pinB, LOW); digitalWrite (pinB, LOW); digitalWrite (pinB, HIGH);
digitalWrite (pinC, HIGH); digitalWrite (pinC, LOW); digitalWrite (pinC, LOW);
digitalWrite (pinD, LOW); digitalWrite (pinD, HIGH); digitalWrite (pinD, LOW);
digitalWrite (pinE, LOW); digitalWrite (pinE, HIGH); digitalWrite (pinE, LOW);
digitalWrite (pinF, HIGH); digitalWrite (pinF, LOW); digitalWrite (pinF, LOW);
digitalWrite (pinG, LOW); digitalWrite (pinG, LOW); digitalWrite (pinG, LOW);
delay(1000); delay(1000); delay(1000);
//5 //7
//3
digitalWrite (pinA, LOW); digitalWrite (pinA, LOW);
digitalWrite (pinA, LOW);
digitalWrite (pinB, HIGH); digitalWrite (pinB, LOW);
digitalWrite (pinB, LOW);
digitalWrite (pinC, LOW); digitalWrite (pinC, LOW);
digitalWrite (pinC, LOW);
digitalWrite (pinD, LOW); digitalWrite (pinD, HIGH);
digitalWrite (pinD, LOW);
digitalWrite (pinE, HIGH); digitalWrite (pinE, HIGH);
digitalWrite (pinE, HIGH);
digitalWrite (pinF, LOW); digitalWrite (pinF, HIGH);
digitalWrite (pinF, HIGH);
digitalWrite (pinG, LOW); digitalWrite (pinG, HIGH);
digitalWrite (pinG, LOW);
delay(1000); delay(1000);
delay(1000);
//8 //9
digitalWrite (pinA, LOW); digitalWrite (pinA, LOW);
digitalWrite (pinB, LOW); digitalWrite (pinB, LOW);
digitalWrite (pinC, LOW); digitalWrite (pinC, LOW);
digitalWrite (pinD, LOW); digitalWrite (pinD, LOW);
digitalWrite (pinE, LOW); digitalWrite (pinE, HIGH);
digitalWrite (pinF, LOW); digitalWrite (pinF, LOW);
digitalWrite (pinG, LOW); digitalWrite (pinG, LOW);
delay(1000); delay(1000);
}
Subject Integration
void setup() {
pinMode (led, OUTPUT);
}
void loop() {
int val = analogRead(potpin);
val = map (val, 1, 1024, 1,
255);
analogWrite (led, val);
}
SESSION 22:BUZZER + PUSHBUTTON
SWITCH
SESSION 22:Buzzer + Pushbutton Switch
Target Outcomes
At the end of these sessions, the students are
able to:
void setup() {
pinMode (led, OUTPUT);
}
void loop() {
val = analogRead(potpin);
analogWrite(led, val);
delay (10);
digitalWrite (led,HIGH);
delay(val);
digitalWrite (led,LOW);
delay(val);
}
BUZZER WITH PUSHBUTTON
SWITCH (ON AND OFF SOUND)
Materials
Microcontroller
USB Cable
Jumper Wire
Breadboard
1 pc. Push Button
1 pc. Active Buzzer
int buzzer = 7;//the pin of the active buzzer
int inPin = 12; //button//
int val;
void setup( )
{
pinMode(buzzer,OUTPUT); //initialize the
buzzer pin as an output
pinMode (inPin, INPUT); //button//
}
void loop( ){
val = digitalRead (inPin);
if (val == LOW) {
digitalWrite(buzzer,HIGH);
}else{
digitalWrite(buzzer,LOW);
}
}
SESSION 23:
BUZZER + PUSHBUTTON SWITCH + LED
Target Outcomes
At the end of these sessions, the students are
able to:
Make combined projects such as: Buzzer +
Pushbutton Switch + LED
Learners will combine all the components that they
have learn from assembly to coding and
troubleshooting with the use of Arduino and basic
electronics.
A BUZZER or BEEPER is an audio signaling device,
which may be mechanical, electromechanical, or
piezoelectric (piezo for short).
PUSH BUTTON/TACT SWITCH reacts to user
interaction with the button or switch when it makes
contact with the control panel beneath.
LIGHT EMITTING DIODE (LED) is a semiconductor
diode that converts electric energy into
electromagnetic radiation at a visible and near
infrared frequencies when its pn junction is forward
biased
Directions: The learners will follow the set up in the
schematic and key in the code for this activity.
PROCEDURE
1. You will be given a set of materials.
2. Connect the circuit properly to buzzer, pushbutton
switch and LED.
3. Key in the given codes in the Arduino IDE.
4. Observe what will happen to the buzzer and LED
every time you press the push button.
Observation: _____________________________
Conclusion: ______________________________
BUZZER + PUSHBUTTON
SWITCH + LED (ALTERNATE
SOUND AND LIGHT)
MATERIALS
Microcontroller
USB Cable
Jumper Wire
Breadboard
1 pc. Push Button
1 pc. Active Buzzer
1 pc. LED (Any Color)
1 pc. 220 Resistors
int buzzer = 7;//the pin of the
active buzzer
int PinButton1 = 12; //button//
int PinLed1 = 10; //led//
void setup()
{
pinMode(PinButton1, INPUT);
digitalWrite(PinButton1,
HIGH); // turn on pull-up !!
pinMode(PinLed1, OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop(){
if(digitalRead(PinButton1) == LOW){
digitalWrite(PinLed1, HIGH);
}
else{
digitalWrite(PinLed1, LOW);
// buzzer
if(digitalRead(PinButton1) == HIGH){
digitalWrite(buzzer, HIGH);
delay (1);
digitalWrite(buzzer, LOW);
delay (1);
}
else{
digitalWrite(buzzer, LOW);
}
}}
SESSION 24:
LED + POTENTIOMETER + SERIAL
MONITOR
Target Outcomes
At the end of these sessions, the students are
able to:
Make combined projects such as: LED +
Potentiometer + Serial Monitor
Learners will combine all the components that they
have learn from assembly to coding and
troubleshooting with the use of Arduino and basic
electronics.
LIGHT EMITTING DIODE (LED) is a semiconductor
diode that converts electric energy into
electromagnetic radiation at a visible and near
infrared frequencies when its pn junction is forward
biased
A POTENTIOMETER is a three-terminal resistor with a
sliding or rotating contact that forms an adjustable
voltage divider.
SERIAL MONITOR is used for communication between
the Arduino board and a computer or other devices.
Directions: The learners will follow the set up in the schematic
and key in the code for this activity.
PROCEDURE
1. You will be given a set of materials.
2. Connect the circuit properly to LED, potentiometer and serial
monitor.
3. Key in the given codes in the Arduino IDE.
4. Observe what will be the output display in the serial monitor
every time you rotate the knob either clockwise or counter
clockwise.
Observation: _______________________________________
Conclusion: ________________________________________
LED + POTENTIOMETER +
SERIAL MONITOR (BLINKING
LED WITH VALUE READING
MATERIALS
Microcontroller
USB Cable
Jumper Wire
Breadboard
1 pc. Potentiometer
1 pc. LED (Any Color)
1 pc. 220 Resistors
int potpin = A0;
int led = 13;
int val = 0;
void setup() {
pinMode (led, OUTPUT);
Serial.begin (9600);
}
void loop() {
val = analogRead(potpin);
Serial.println (val);
analogWrite(led, val);
delay (10);
digitalWrite (led,HIGH);
delay(val);
digitalWrite (led,LOW);
delay(val);
}
LED + POTENTIOMETER
+ SERIAL MONITOR
(BLINKING LED WITH
VALUE READING)
Materials
Microcontroller
USB Cable
Jumper Wire
Breadboard
1 pc.7 Segment
1 pc. LED (Red and Green)
3 pc. 220 Resistors
int pinA = 2;
int pinB = 3;
int pinC = 4; pinMode (pinA, OUTPUT);
int pinD = 5; pinMode (pinB, OUTPUT);
int pinE = 6; pinMode (pinC, OUTPUT);
int pinF = 7; pinMode (pinD, OUTPUT);
int pinG = 8; pinMode (pinE, OUTPUT);
int ledR = 9; pinMode (pinF, OUTPUT);
int ledG = 10; pinMode (pinG, OUTPUT);
pinMode (ledR, OUTPUT);
void setup() { pinMode (ledG, OUTPUT);
}
void loop() {
//red
digitalWrite (ledR, HIGH);
//5
digitalWrite (pinA, LOW); //4
digitalWrite (pinB, HIGH); digitalWrite (pinA, HIGH);
digitalWrite (pinC, LOW); digitalWrite (pinB, LOW);
digitalWrite (pinD, LOW); digitalWrite (pinC, LOW);
digitalWrite (pinE, HIGH); digitalWrite (pinD, HIGH);
digitalWrite (pinF, LOW); digitalWrite (pinE, HIGH);
digitalWrite (pinG, LOW); digitalWrite (pinF, LOW);
delay(1000); digitalWrite (pinG, LOW);
delay(1000);
//3
digitalWrite (pinA, LOW);
digitalWrite (pinB, LOW); //2
digitalWrite (pinC, LOW); digitalWrite (pinA, LOW);
digitalWrite (pinD, LOW); digitalWrite (pinB, LOW);
digitalWrite (pinC, HIGH);
digitalWrite (pinE, HIGH);
digitalWrite (pinD, LOW);
digitalWrite (pinF, HIGH); digitalWrite (pinE, LOW);
digitalWrite (pinG, LOW); digitalWrite (pinF, HIGH);
delay(1000); digitalWrite (pinG, LOW);
delay(1000);
//1 //green
digitalWrite (pinA, HIGH); digitalWrite (ledG, HIGH);
digitalWrite (pinB, LOW); //8
digitalWrite (pinC, LOW); digitalWrite (pinA, LOW);
digitalWrite (pinD, HIGH); digitalWrite (pinB, LOW);
digitalWrite (pinE, HIGH); digitalWrite (pinC, LOW);
digitalWrite (pinF, HIGH); digitalWrite (pinD, LOW);
digitalWrite (pinG, HIGH); digitalWrite (pinE, LOW);
delay(1000); digitalWrite (pinF, LOW);
digitalWrite (ledR, LOW); digitalWrite (pinG, LOW);
delay(500); delay(1000);
//7
digitalWrite (pinA, LOW);
digitalWrite (pinB, LOW); //6
digitalWrite (pinC, LOW); digitalWrite (pinA, LOW);
digitalWrite (pinD, HIGH); digitalWrite (pinB, HIGH);
digitalWrite (pinE, HIGH); digitalWrite (pinC, LOW);
digitalWrite (pinF, HIGH); digitalWrite (pinD, LOW);
digitalWrite (pinG, HIGH);
digitalWrite (pinE, LOW);
delay(1000);
digitalWrite (pinF, LOW);
digitalWrite (pinG, LOW);
delay(1000);
//5 //4
digitalWrite (pinA, LOW); digitalWrite (pinA, HIGH);
digitalWrite (pinB, HIGH); digitalWrite (pinB, LOW);
digitalWrite (pinC, LOW); digitalWrite (pinC, LOW);
digitalWrite (pinD, LOW); digitalWrite (pinD, HIGH);
digitalWrite (pinE, HIGH); digitalWrite (pinE, HIGH);
digitalWrite (pinF, LOW); digitalWrite (pinF, LOW);
digitalWrite (pinG, LOW); digitalWrite (pinG, LOW);
delay(1000); delay(1000);
//3 //2
digitalWrite (pinA, LOW); digitalWrite (pinA, LOW);
digitalWrite (pinB, LOW); digitalWrite (pinB, LOW);
digitalWrite (pinC, LOW); digitalWrite (pinC, HIGH);
digitalWrite (pinD, LOW); digitalWrite (pinD, LOW);
digitalWrite (pinE, HIGH); digitalWrite (pinE, LOW);
digitalWrite (pinF, HIGH); digitalWrite (pinF, HIGH);
digitalWrite (pinG, LOW); digitalWrite (pinG, LOW);
delay(1000); delay(1000);
//1
digitalWrite (pinA, HIGH);
digitalWrite (pinB, LOW);
digitalWrite (pinC, LOW);
digitalWrite (pinD, HIGH);
digitalWrite (pinE, HIGH);
digitalWrite (pinF, HIGH);
digitalWrite (pinG, HIGH);
delay(1000);
digitalWrite (ledG, LOW);
delay(500);
}
LET’S EVALUATE AND REVIEW