Arduino Study Guide
Arduino Study Guide
STUDY GUIDE
CIRCUI
TS
IMPORTANT
DEFINITIONS
5 GND SIGN
V AL
Ground,
Voltage or
Tierra or
positive The pins in
negative
Red line in the
Blue line in
the Arduino
the
Bredboard
Breadboar
d
W ires color W ires color W ires color
code: code: code:
Red Black Blue
Yellow Gree
Brow n
Orang n Purpl
e Grey e
White
5 Voltage or positive
V (red) line
You can also find it as
VCC
• This is where we are going to connect all the
positive sides of our components.
Digital Pins
• This is where we are going to connect the
signal side
of our components..
LED’S AND PB
SIGNAL
PUSH
BUTTON
SIGNAL
PB
GROUND
5 GND LED’S
v GROUND PB
VOLTAGE
*PB: Push
button
COMPONENTS
CONNECTION
LED BUZZER PUSH
BUTTON
SIGN
AL
+ -
+-
+ -
When we only have one positive side and one negative side but not a
third side meant for signal, we take the positive side as signal, that’s In this case we do have a signal side so
why we connect the positive side of the LED and the buzzer directly the right way to connect it is by using
to the pins. three sides, one for positive, one for
We do this because we need to control the components with the negative and one for signal.
Arduino and if we don’t connect any side to a pin, we will not be able
to send or receive any signals.
EXAMP
LE
LED’S POSITIVE REMEMBER TO
SIDE USE THE
CONNECTED TO RESISTOR
SIGNAL
PB
SIGNAL
BUZZER’S POSITIVE
SIDE
CONNECTED TO
SIGNAL
BUZZER
NEGATIVE
LED
NEGATIVE
5 GND PB PB
POSITI NEGATI
v VE VE
REMEMBER TO USE
THE
RESISTOR
*PB: Push
button
COD
E
IMPORTANT
DEFINITIONS
Void Setup
• The setup() function runs once when you turn on your Arduino or reset it.
• This is where you tell the Arduino what to do when it starts, like setting up pins or
initializing
sensors.
Example
IMPORTANT
DEFINITIONS
Void loop
• Everything inside loop() repeats over and over until you turn the Arduino off.
It’s like the main part of your code that keeps your project going.
Example
IMPORTANT
DEFINITIONS
pinMode
• This function sets up a pin as either an input or output. You use it in the setup()
function to tell the Arduino if a pin will be sending a signal (output) or reading a signal
(input).
Examp
le
IMPORTANT
DEFINITIONS
digitalRe
ad
• This function is used to read the value from a digital input pin. If the pin is
connected to a
button or a sensor, digitalRead() will tell you if it’s getting a signal (HIGH or
LOW).
Examp
le
IMPORTANT
DEFINITIONS
digitalWri
te
• This function sends a HIGH (on) or LO W (off) signal to a digital output pin. It’s
how you turn
things like LEDs or motors on or off.
Examp
le
IMPORTANT
DEFINITIONS
dela
y
• This function pauses the program for a certain amount of time (in milliseconds)
delay(1000) makes the Arduino wait for 1 second before moving on to the next
line of code.
Examp
le
UNDERSTANDING THE
CODE
Code to turn 3 LEDs ON using a
Push Button
We define the pins and give a name to our constants and variables
states (on/off) Inside the setup we define our inputs and outputs
If the button is being pressed, turn LED on, then wait for 1 sec
and turn LED_2 on, then wait for 1 sec and turn LED_3 on
If the button is being pressed, turn LEDs from pin 2 to 5 ON, one
by one waiting 1.5 sec between each.
Then turn the LEDs off one by one waiting 2 sec. B etween each