[MUSIC PLAYING]
[MUSIC PLAYING]
This is an Arduino.
You can use it to make a t-shirt
that blinks for your best
friend's birthday.
You can ask a robot to make you
a sandwich when you're hungry.
You can even make a device that
asks all your plants to tweet
when they're thirsty so that
you don't forget to water them,
and you can also
make blinds that
synchronize with
your alarm clock
so that, when your alarm
clock goes off in the morning,
it can wake you up.
It's pretty cool.
Huh?
Artists, designers,
and hobbyists
all use Arduino to
achieve their purposes.
In fact, the Arduino is like
the glue that makes stuff work.
There's a bunch of
documentation on Arduino website
if you need general pointers.
But even if you
don't know anything
about electronic or
microcontrollers, that's OK.
Arduino is the
friendliest way to start
learning about electronics
so that you can control them.
Let's start playing with Arduino
by making a row of blinking LED
lights in our first project.
Here are the things
that you need.
One, you need an Arduino board.
This one is an Arduino Uno.
You will also need
an A to B USB cable.
You need some LEDs, and I
use five in this tutorial.
You need a breadboard
and then some wires.
You also need the
Arduino software, which
you can download at Arduino.cc.
For any Arduino project, there
are two necessary components--
the hardware and the software.
Everything you see
here is the hardware.
For our project, we will
start with the hardware part
and then progress
to the software.
And then finally, we
will join the two.
This is an LED.
It has two legs and a body.
You may notice that one leg
is shorter than the other.
The shorter leg goes to
ground, and the longer leg
goes to the positive
voltage source.
The LED is directional.
That means, if you
accidentally plug the longer
leg into a negative
voltage source,
the circuit is not valid
and that LED won't light up.
This is a breadboard.
It is very useful for trying
out new electronic circuits.
Hidden inside a breadboard
are many components.
If you look at the
breadboard this way,
the row with the red plus
and blue negative signs
are linked horizontally
in the row.
The remaining holes are
connected vertically
in columns of five
holes, and there
is no link across the
horizontal gap in the middle
of the breadboard.
The Arduino's operating
power is 5 volts.
There are many components
on the Arduino.
And together, they make it
a powerful microcontroller.
For our blinking
light project, we
will be focusing on these pins.
They are digital pins,
which means they can only
have two states-- high and low.
For this project, we'll be using
pins 8 through 12 and ground.
This is a simple
schematic of how we will
be assembling the hardware.
The black wire all
the way at the top
connect to ground
on the Arduino,
and the colored wires connect
the pins on the Arduino
to the power end of
the respective LEDs.
The assembly process
is not difficult.
Here's the breadboard, the
five LEDs we'll be using.
First, lay the
LEDs out like this.
The longer leg-- the one to
power-- goes to the left,
and the shorter leg, which
is the leg to ground,
on the right.
Now, place the LEDs
into the small holes
in the breadboard like this.
Next, we will be placing the
wires into the breadboard.
The black wires are
for ground connections,
and the colored wires will go to
pins on the Arduino for power.
Place one end of a black
wire in the negative row.
That row is connecting
horizontally
and will become grounded.
Then get five more
black wires and put one
into each column,
which is connected
to the ground leg of an LED.
Remember, the columns of five
holes are connected vertically.
Next, we need to connect
the other end of these five
black wires to ground.
Since we have dedicated
a negative horizontal row
to be ground, we can connect
each of these five wires
to any hole in that row.
We now need to connect a
colored wire to each LED.
These likely needs power.
You have five colored
wires, and put one
into each column which is
connected to a power leg
an in an LED.
Now that we've finished making
a circuit on our breadboard,
we need to think about which
pins these wires connect to
on the Arduino.
The black wire goes to ground.
The red wire here
goes to pin 12.
The green wire goes to 11.
The yellow wire goes to pin 10.
The green one here
goes to pin 9,
and the last red
one goes to pin 8.
Take a moment to locate
these pins on your Arduino.
All right.
You can go ahead
and put these wires
into their respective pins.
Make sure you connect
into the right ones.
Otherwise, the LEDs
won't light up correctly.
This concludes the hardware
portion of the project.
Now, let's move on
to the software part.
Here, we rest on instructions
and code called "sketches"
to tell our Arduino what to do.
After you've downloaded
Arduino's software,
you open it up and get
a screen like this.
Set up is called when
the sketch starts.
It's used to initiate
variables, pin modes, start
using libraries, and et cetera.
It will only run once
after each power up
or reset of the Arduino board.
Here, we use set up to
configure the mode of each pin.
Loop.
Loops consecutively
and allows the program
to change or respond as it runs.
The code in this
section runs repeatedly.
In this example, we use
loop to continuously
turn the LEDs on and off.
We will be using pins 8 to
12 to power out the LEDs,
so we configure them
to be output pins.
Now, let's move on to the
loop section of the code.
When a pin is configured
to output with pin mode
and set to high, it
is outputting 5 volts.
In this case, the pin
will turn the LED on.
Then we wait for a second.
And now, we write the
pin to low-- setting it
as 0 volts, which
turns the LED off.
We wait for a second again
before lighting the next LED.
You see we repeat
these four lines
of code for the other
LEDs-- changing the pin
number respectively, though.
The entire code looks like this.
Notice that our LEDs behave
similarly and most of the code
was copy and pasted.
As you become more
familiar with programming,
you will use loops to
achieve the same effect.
The final step is to upload
a sketch onto the Arduino.
You need to connect the
square-ish end of the USB
to the Arduino and the
other end to the computer.
Afterwards, click
on the Upload button
to load a sketch into Arduino,
and then look at the lights.
You can play around
with this example.
Say you want the
lights to blink faster.
You can achieve this
by changing the delay
value from 1,000 milliseconds
to 500 milliseconds.
The light will blink faster
because you told the program
to wait for half a second
instead of a whole second
before turning
the LED off again.
The Arduino is cool
because you can
change the software very
easily and achieve a responding
effect.
The Arduino allows
you to quickly change
something in code to see what
different ideas will play out
to be.
Thank you watching this tutorial
and doing this blinking light
project with me.
I hope you've had fun and
learned a bit at the same time
about the Arduino.
Thanks, and I'll
see you next time.
[MUSIC PLAYING]
[MUSIC PLAYING]
