ARDUINO
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.
• As there is only one 5v Input in the Arduino, we
must use the RED bus line in the
5V is W ir
Breadboard to connect. everything.
here e
• And then we connect one jumper wire from
the RED bus line to the 5V input in the
Arduino, in order to give power to all the
circuit.
Red bus line is
here
1 GND here
GN Ground, Tierra or negative
D (blue) line
• This is where we are going to connect all the
negative sides of our components.
• As there are only three GND Inputs in the
Arduino, we must use the BLUE bus line in
the Breadboard to connect. everything.
2 GND are
here
• And then we connect one jumper wire from the
BLUE bus line to one of the GND inputs in
the Arduino, in order to give ground to all the
circuit. W ir
e
• You can use any GND you like.
Blue bus line is
here
SIGN The pins in the
AL Arduino
Digital Pins
• This is where we are going to connect the
signal side
of our components..
• One side must be connected to the pins we
have in the Arduino, 2-13 for digital pins and
A0-A5 for Analogue pins.
• The other side must be connected to our
Analogue
components
Pins
signal side.
• Here is where the Arduino gets to control the
circuit by sending and receiving signals.
EXAMP
LE
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
• The loop() function is where your Arduino program continuously runs.
• 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
We create a variable so we can use the push button with two
states (on/off) Inside the setup we define our inputs and outputs
Now inside the loop
Read the value from our push
button
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 not being pressed, turn
everything off
UNDERSTANDING THE
CODE
Code to turn 4 LEDs ON using a Push Button
and For Cycles
We define the pins and give a name to our constants and variables
We create a variable so we can use the push button with two
states (on/off)
Inside the setup we define our inputs and
outputs Now inside the loop
Read the value from
our push button
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
After that turn all LED’s On at the same time (no
delay here) Then wait for 4 secs.
And finally turn all LED’s off at the same time.