Professional Documents
Culture Documents
Lesson 1 Blinking Leds
Lesson 1 Blinking Leds
To get an LED to turn on, Grab an LED. Take the long leg, and plug it into
D12, and the short leg into GND, like in the diagram below.
D12 is where we will send our electricity out of (Our positive, +, or cathode), and
GND(negative, -, or Anode) is where the electricity will flow to complete our circuit.
GND has an assumed voltage of 0.
Why?
“So, where do you find a higher voltage and a lower voltage? Here's something really
useful to know: every source of electricity has two sides. You can see this on
batteries, which have metal caps on both ends, or your wall outlet that has two (or
more) holes. In batteries and other DC (Direct Current) voltage sources, these sides
(often called terminals) are named positive (or "+"), and negative (or "-").
Why does every source of electricity have two sides? This goes back to the idea of
“potential”, and that you need a voltage difference in order to get electricity to flow. It
sounds silly, but you can’t have a difference without two things to be different. In any
power supply, the positive side will have a higher voltage than the negative side, which
is exactly what we want. In fact, when we measure voltage, we usually say that the
negative side is 0 volts, and the positive side is however many volts the supply can
provide.
Once your LED is placed like the diagram above, you’re ready for coding the LED to
blink!
Open your Arduino application, and open a new file window if need be, so your screen
looks like this:
Notice the weird curly brackets on lines 1, 4, 6, and 9? All code needs to be placed in
between those curly brackets. Think of the curly brackets as the paragraph markers of
your code. It's how you tell your computer what lines of code are a part of which section.
Make sure not to delete those, or delete the void setup or void loop. You need both to
run your code!
All the code you want to run only once you place inside the curly brackets of void setup.
All the code you want to run in a loop, over and over again, place inside the curly
brackets in void loop.
Now you’re finally ready to run your code. To make sure your Arduino board is
connected to your computer, click on the top bar Tools -> Port -> and then click on the
port which says (Arduino Uno) after the COM.
Note: if you get an error - try clicking tools -> port and make sure the port that has
(Arduino Uno) at the end of it is selected.
Now, try to play around with the delays. How low can you go with the delays until you can’t see
the blink?