B & B

HOW TO


Blink an LED with Arduino

Make an LED turn on and off periodically using an Arduino and a few simple components.

What you'll need:

Wiring:

  1. Place the LED on the breadboard. Note which leg is longer (the anode / positive leg) and which is shorter (the cathode / negative leg).
  2. Connect the longer leg (positive +) to one end of the 220Ω resistor.
  3. Connect the other end of the resistor to pin 13 on the Arduino using a jumper wire.
  4. Connect the shorter leg (negative -) of the LED to the ground rail on the breadboard using a jumper wire.
  5. Connect the ground rail of the breadboard to the Arduino's GND pin using a jumper wire.
Diagram of an LED showing the longer anode leg and shorter cathode leg

Arduino. (2024, January 30). How are the LEDs represented in the Starter Kit projects book? [Image]. https://support.arduino.cc/hc/article_attachments/12416016395676

Circuit diagram of the LED blink project wired on a breadboard

Circuit diagram created using Tinkercad (https://www.tinkercad.com/).

Code:

void setup() {
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
}
  1. Open the Arduino IDE and paste in the code above.
  2. Under Tools, select your board (e.g. Arduino Uno) and the correct port.
  3. (if you are unsure which port to select, disconnect your Arduino and check the list of ports, then reconnect it and see which new port appears)
  4. Click Upload.
The Arduino IDE showing the Blink sketch ready to upload

Söderby, K., & Hylén, J. (2024, January 17). Getting Started with Arduino IDE 2. Arduino Documentation. https://docs.arduino.cc/software/ide-v2/tutorials/getting-started-ide-v2/

Troubleshooting:

Once the upload finishes, the LED should turn on and off once per second. If it isn't working as expected, check the following:

Video demonstration:

Science Buddies. (2022, October 22). How to blink an LED with Arduino (Lesson #2) [Video]. YouTube. https://www.youtube.com/watch?v=FKekzzj5844

Tutorials

More how-to guides coming soon.

B&B Chatbot