Blinking an LED on an Arduino board

Arduino is a flexible open-source electronics platform that has sparked the interest of artists worldwide. Arduino has gained popularity among novice and expert manufacturers with its simple interface and active enthusiast community. In this Answer, we'll make an exciting yet straightforward project using an Arduino board to make an LED blink. This project will help you better grasp Arduino's capabilities and open the door to even more intriguing electronic projects in the future. Let's plunge in and explore the Arduino universe!

Blinking an LED blink using Arduino

To make an LED blink on an Arduino board, follow these steps:

Hardware required

  • Arduino board (e.g., Arduino Uno)

  • USB cable to connect the Arduino board to the computer

  • LED (any color)

  • 220-ohm resistor (or close value)

  • Jumper wires

Circuit connections

  1. Connect the LED's longer leg (anode) to one leg of the resistor.

  2. Connect the other leg of the resistor to the digital pin 13 on the Arduino board.

  3. Connect the LED's shorter leg (cathode) to the ground (GND) pin on the Arduino board.

Circuit diagram
Circuit diagram

Code

void setup() {
pinMode(13, OUTPUT); // Set digital pin 13 as an output
}
void loop() {
digitalWrite(13, HIGH); // Turn the LED on (HIGH voltage)
delay(1000); // Wait for 1 second (1000 milliseconds)
digitalWrite(13, LOW); // Turn the LED off (LOW voltage)
delay(1000); // Wait for 1 second (1000 milliseconds)
}
Code to blink an LED

Upload the code

  1. Connect your Arduino board to the computer using the USB cable.

  2. Open the Arduino IDE and copy the code into a new sketch.

  3. Select the correct board and port under the "Tools" menu.

  4. Click on the checkmark icon (✓) to verify the error code. Fix any errors that appear.

  5. Click on the right-arrow icon (➔) to upload the code to your Arduino board.

Observation

After successfully uploading, the LED (connected to pin 13) will start blinking. The LED will turn on for one second and then turn off for one second repeatedly.

This basic example demonstrates how to control the state of an LED (on/off) using an Arduino board. You can modify the delay times or add more LEDs to experiment with different blinking patterns and create more advanced projects.

Copyright ©2024 Educative, Inc. All rights reserved