Circuit Creation

LED Blinking Project using Arduino

The LED blinking project is the first and most basic Arduino project. It helps beginners understand how Arduino outputs work and how to control electronic components using code.

Beginner

Components Required

Circuit Connections

Follow the steps below to connect the LED with the Arduino board. Make sure the Arduino is not connected to USB while wiring.

  1. Insert the LED into the breadboard. The longer leg (anode) is positive.
  2. Connect a 220Ω resistor to the shorter leg (cathode) of the LED.
  3. Connect the other end of the resistor to GND on Arduino.
  4. Connect the longer leg of the LED to digital pin 13.
Arduino LED blinking circuit connection

here is the circuit diagram for reference.

Arduino Code

                
                // LED Blinking Project
                // Arduino Hub

                int ledPin = 13;

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

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

Upload the Code

  1. Connect the Arduino board to your computer using the USB cable.
  2. Open the Arduino IDE and paste the code into a new sketch.
  3. Select the correct board and port from the Tools menu.
  4. Click the Upload button.

Code Explanation

Let us understand how the Arduino code works step by step. This will help you modify the project later and build more projects.

Declaring the LED Pin

int ledPin = 13; stores the pin number where the LED is connected. Using a variable makes the code easier to read and change.

setup() Function

The setup() function runs only once when the Arduino starts. Here, we tell Arduino that the LED pin will work as an output.

loop() Function

The loop() function runs continuously. Inside this loop, the LED is turned ON and OFF repeatedly, creating the blinking effect.

delay() Function

The delay(1000) function pauses the program for 1000 milliseconds (1 second). Changing this value will change the blinking speed.

Common Mistakes & Troubleshooting

What You Learned