Blink An LED Using Arduino

Blink

This example shows the simplest thing you can do with an Arduino to see physical output: it blinks an LED.

Hardware Required

  • Arduino Board
  • LED
  • Resistor, anything between 220 ohm to 1K ohm

Circuit

To build the circuit, connect one end of the resistor to Arduino pin 13. Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor. Connect the short leg of the LED (the negative leg, called the cathode) to the Arduino GND, as shown in the diagram and the schematic below.Blink

Most Arduino boards already have an LED attached to pin 13 on the board itself. If you run this example with no hardware attached, you should see that LED blink.

image developed usingĀ Fritzing. For more circuit examples, see theĀ Fritzing project page

Schematic

After you build the circuit plug your Arduino board into your computer, start the Arduino IDE, and enter the code below.

Code

In the program below, the first thing you do is to initialize pin 13 as an output pin with the line

pinMode(13, OUTPUT);

In the main loop, you turn the LED on with the line:

digitalWrite(13, HIGH);

This supplies 5 volts to pin 13. That creates a voltage difference across the pins of the LED, and lights it up. Then you turn it off with the line:

digitalWrite(13, LOW);

Blink Schematic

 

Read more: Blink An LED Using Arduino

Leave a Comment

Your email address will not be published. Required fields are marked *