DEV Community

Cover image for Blinking an LED with Arduino
AMANI Eric
AMANI Eric

Posted on

Blinking an LED with Arduino

Blinking an LED is a fundamental project for Arduino enthusiasts. In this tutorial, we'll go through the process of blinking an LED using the Arduino uno R4 WIFI (steps same for most Arduino boards) and a breadboard. Let's get started!

Materials Needed:

  1. Arduino Board (Ex: uno)
  2. Breadboard and jumper wires
  3. LED
  4. Resistor (270Ω)
  5. USB cable for Arduino
  6. Arduino IDE installed on your computer

Image description

Step 1: Set Up the Hardware:

  1. Connect the short leg (cathode) of the LED to GND on the Arduino.

  2. Connect the long leg (anode) of the LED to resistor ( 270Ω) and to pin 13 on the Arduino.

You can connect the components differently on breadboard as long as you follow the same circuit its fine.

Image description

Step 2: Connect your Arduino board to your computer

Cables can be different depending on Arduino board. Some can use USB and others Type-C cables. Can connect depending on your board.

Step 3: Writing the codes

In your Arduino IDE add those codes.

// Blinking a single LED
int ledPin = 13; // Pin number for the LED

void setup() {
  pinMode(ledPin, OUTPUT); // Sets the LED pin as an output
}

void loop() {
  digitalWrite(ledPin, HIGH); // Turn the LED on
  delay(1000); // Wait for 1 second
  digitalWrite(ledPin, LOW); // Turn the LED off
  delay(1000); // Wait for 1 second
}
Enter fullscreen mode Exit fullscreen mode

Step 4: Uploading the codes

Now, make sure that in your Arduino IDE the correct board is selected and click on the upload button.

Image description

Your codes should be uploaded successfully.

If the steps above were followed, the led will be blinking every one second 🎉

You can read more on the article 👉🏾here

If you liked this post, you might as well like to checkout on fading an LED.
Fading an LED

Top comments (0)