Feb 122011

One of the first and simplest sketches to run on your Arduino is to make an LED blink. If this is your first time using Arduino, read through our “Arduino basics: getting started” article.

Connecting the Arduino and LED

Connect your Arduino to your computer using a USB cable. The power light should come on.

1) Place your LED and a 470 ohm resistor in series (a breadboard will help). Always use resistors with LEDs for safety purposes, and remember that the LED cathode points toward Ground.

2) Connect jumper wires to pins 13 and Gnd on the digital side of the Arduino

3) Open the arduino IDE and type in the following code:

void setup() {
    pinMode(13, OUTPUT);
void loop() {
  digitalWrite(13, HIGH);
  digitalWrite(13, LOW);

4) Press the upload button in the IDE to send the code to your Arduino. It should automatically start running it!

Video of the LED blinker in action

(includes code explanation):


Modify the LED blink sketch:

  • You can change the blink rate by changing the delay!
  • You may have also noticed a little yellow LED on the board that blinks in time with your LED. That little LED is wired to pin 13 and is used for testing purposes. If you want to avoid it, use a different pin (such as pin 12). But remember to modify the code (see below)
void setup() {
    pinMode(12, OUTPUT);
void loop() {
  digitalWrite(12, HIGH);
  digitalWrite(12, LOW);

The above code is modified to use pin 12 (instead of pin 13) and to only delay for 500 ms. Try your own variations!

Jan 302011

This project requires you to be somewhat comfortable with the breadboard and placing components in the proper sequence.

In particular, pay attention to:

  • The negative stripe on the capacitors (should always point to ground)
  • The pins of the transistors (its helpful to know which are E,B, and C)

To build this circuit:

  • 9V battery or power source
  • Transistors (two NPN, we used 2n3904)
  • Capacitors (we used 100uF)
  • LEDs (2)
  • resistors (2 of 10k Ohms)
  • resistors (2 of 470 Ohms)
  • push button switch
  • jumper wires

Alternative breadboard layout for LED flasher:

If you want a simpler layout with less jumper wires, here’s another version we built. It’s the same circuit, but the transistors and capacitors mirror each other so be mindful of polarity!

alternate layout

Video of dual LED flasher in action:

where I test the circuit in Ktechlab before showing the build test