[Arduino blink circuit]

Arduino: Blink an LED

  1. Plug your Arduino in to the computer's USB port. A power light should come on.

  2. Run the Arduino software.
  3. Open the Blink sketch: File->Examples->Basics->Blink
    Arduino programs are called sketches.A

  4. Wire up your LED as shown at right.

    LEDs only pass current in one direction: the longer leg has to connect to the positive + side of the circuit, the shorter leg to the ground (negative) side.
    So you want the shorter leg of the LED going (via a black wire) to Gnd;
    the longer leg going via a resistor to pin 13.
    Whenever you use an LED, you always want to include a resistor. Otherwise, you'll overload the LED and it will blow out. It doesn't matter whether you put the resistor before the LED or after it, on the + side or on the ground side, as long as it's there.

    [Arduino upload button]
  5. Back in the window for the Blink sketch, click: Upload

    The sketch should upload to the Arduino, and you should see some lights on the Arduino flash.
    Then your LED should start blinking.

Blink an LED, page 2

Arduino sketches

setup is run once, when the program first starts running.

loop is run over and over, forever.

digitalWrite writes to one of the Arduino's pins.

delay waits that many milliseconds (thousandths of a second) before continuing the program.

Make it blink faster or slower

Now try to make it blink faster or slower -- how would you do that?

Add a second LED

Now add a second LED, and make it the opposite of the first one: when your red LED is on, the green one is off, and vice versa. (Hint: plug the second LED into a different pin. How about adding a second LED? Can you make them blink together? (Hint: you can use any of the Arduino's digital pins, not just 13.)

How about making one LED be ON while the other is OFF?

If you get something that works, you can save it, using File->Save as. Give it a name describing what it does, like 2led or one-on-one-off. Any time you change a sketch to make it do something new, you can save it to a new name -- that way you can go back to it later.

Too easy? Try a problem that's a little harder: make your two LEDs blink at different rates. For instance, make the green one blink twice as fast as the red one.