Blinking an LED with Arduino

Blinking an LED With Arduino

The first project that comes to mind after buying Arduino is always to blink an LED. It is the simplest, and it is also beautiful to look at. This type of project doesn’t require any particular experience, so don’t worry. Blinking an LED with Arduino is easier than you might think. Let’s see the project.

Required components

For this project, you need the following components:

  • 1 Breadboard
  • 1 Arduino Uno
  • 1 LED
  • 1 resistor (220Ω)
  • 2 wires

Circuit

  • Connect the LED to the breadboard.
  • Put the resistor in series on the longest pin of the LED (positive side, anode).
Blinking an LED with Arduino
  • Connect a wire from digital pin 7 of Arduino to the resistor.
  • Finally connect a wire to the GND (ground) pin of Arduino to the free pin of the LED.

Sketch

  • Plug Arduino into your computer.
  • Launch Arduino IDE.
  • Load the following code.
void setup() {
  pinMode(7,OUTPUT);
}

void loop() {
  digitalWrite(7,HIGH);
  delay(1000);
  digitalWrite(7,LOW);
  delay(1000);
}

Once the sketch has been loaded, we will see the LED turn on and off.

Conclusion

The setup function is executed only once, while loop as the name suggests is executed continuously.

Within the setup function we define pin 7 as output via the pinMode function. In the loop function we turn the LED on and off with the digitalWrite function, which expects two input parameters, the pin and an integer (1 on, 0 off), finally we use the delay(milliseconds) function in order to delay by one second the turning on and off of the LED.

As you have seen, blinking an LED is a very simple project but at the same time it is a great starting point with Arduino.

Lorenzo Miscoli

Software Developer specialized in creating and designing web applications. I have always loved technology and dreamed of working in the IT world, to make full use of my creativity and realize my ideas.
Scroll to Top