Arduino LED blinking project

Photo of author

By Jackson Taylor

Home » Arduino » Arduino LED blinking project

As an Amazon Associate we earn from qualifying purchases.

Are you excited to dive into the world of Arduino projects? One of the simplest yet most rewarding starter projects is the LED blinking project. This hands‑on activity will teach you the basics of coding, wiring, and understanding Arduino microcontrollers.

What You Need for the Arduino LED Blinking Project

Before we get started, gather the following materials:

  • Arduino board (Uno is a popular choice)
  • LED (any color you like)
  • Resistor (220 ohms to protect the LED)
  • Breadboard
  • Jumper wires
  • USB cable (to connect Arduino to your computer)
  • Arduino IDE (software for coding your Arduino)

Step 1: Setting Up Your Workspace

Creating a well‑organized workspace is crucial for a smooth and enjoyable Arduino LED blinking project. Think of it as building a solid foundation before you start assembling the pieces. Here’s how you can set yourself up for success:

Hardware Hack

Stop Buying New Batteries for Your Tech

Electronics are expensive, but their power sources don't have to be. Discover the simple engineering trick to recondition dead batteries and bring your gadgets back to 100% capacity.

Watch the Free Video

Choosing the Right Workspace

Find a clean, flat surface with enough space to spread out your components. A desk or table with good lighting is ideal. Avoid areas with a lot of dust or moisture, as these can interfere with your electronic components.

Organizing Your Tools and Components

Before you start, arrange all the components neatly in front of you. Use small containers or trays to separate items like resistors, LEDs, and jumper wires. This reduces the chances of misplacing critical parts.

  • Arduino Board: Place it at the center for easy access.
  • Breadboard: Position it close to the Arduino board.
  • Jumper Wires: Lay them out so you can quickly grab the lengths you need.
  • USB Cable: Keep it plugged into your computer for convenience.

Installing the Arduino IDE

If you haven’t already, download and install the Arduino IDE from the official Arduino website. Follow these steps:

  1. Go to Arduino’s software page.
  2. Download the version compatible with your operating system (Windows, macOS, or Linux).
  3. Install the software and launch it.
See also
Arduino LED fading project

After installation, ensure the IDE recognizes your Arduino board by selecting the correct board type and port under the Tools menu.

Avoiding Static Electricity Issues

Static electricity can damage your electronic components. To minimize this risk:

  • Work on an anti‑static mat if possible.
  • Ground yourself by touching a metal object before handling the Arduino board.

Safety Precautions

While this project is safe and beginner‑friendly, a few precautions go a long way:

  • Never work with wet hands or near water.
  • Double‑check connections before powering up the Arduino.
  • Use proper resistors to prevent components from overheating.

Testing Your Arduino Setup

Before connecting anything, test your Arduino board to ensure it’s functioning correctly:

  1. Plug the Arduino into your computer using the USB cable.
  2. Open the Arduino IDE and load the “Blink” example from File > Examples > Basics > Blink.
  3. Click Upload and watch the onboard LED (Pin 13) blink.

If the onboard LED blinks as expected, your Arduino is ready to power your project. If not, troubleshoot the board connection and verify the IDE setup. A well‑prepped workspace not only saves time but also enhances the overall experience. Once everything is in place, you’re ready to dive into the exciting world of Arduino projects

Step 2: Connecting the LED to the Arduino

Wiring the LED

  1. Insert the LED into the breadboard.
  2. Connect the longer leg (anode) of the LED to a digital pin on the Arduino (e.g., Pin 13) using a jumper wire.
  3. Attach a resistor to the shorter leg (cathode) of the LED.
  4. Connect the other end of the resistor to the GND (ground) pin on the Arduino.

Why Use a Resistor?

A resistor prevents excessive current from damaging your LED, ensuring it blinks correctly.

Step 3: Writing the Arduino Code

The Basic LED Blinking Code

Open the Arduino IDE and paste the following code into the editor:

Sustainable Tech

Keep Toxic E-Waste Out of Landfills

Don't throw away your failing laptop, phone, or car batteries. Learn how to recondition them at home in just a few hours. It's better for the planet—and your wallet.

Learn How It Works
void setup() { 
pinMode(13, OUTPUT); // Set pin 13 as an output 
}
void loop() { 
digitalWrite(13, HIGH); // Turn the LED on 
delay(1000); // Wait for 1 second 
digitalWrite(13, LOW); // Turn the LED off 
delay(1000); // Wait for 1 second 
}

Understanding the Code

  • setup(): Configures the pin mode for the LED.
  • loop(): Repeats the instructions to blink the LED.
  • digitalWrite(): Turns the LED on (HIGH) and off (LOW).
  • delay(): Pauses the program for a specified time in milliseconds.
See also
How to control an LED with Arduino

Step 4: Uploading the Code to Arduino

  1. In the Arduino IDE, select your board type and port under the “Tools” menu.
  2. Click the Upload button (the arrow icon).
  3. Wait for the “Done Uploading” message in the IDE.

Step 5: Watching the LED Blink

Once the code is uploaded, the LED connected to Pin 13 will start blinking. If it doesn’t, double‑check your wiring and code.

Customizing Your LED Blinking Project

Adjusting the Blinking Speed

You can modify the delay() values in the code to change the blinking speed. For example:

  • delay(500) for faster blinking.
  • delay(2000) for slower blinking.

Adding Multiple LEDs

Want to add more LEDs? Follow these steps:

  1. Connect additional LEDs to different digital pins (e.g., Pins 12, 11, etc.).
  2. Update your code to control each LED.

Example:

void setup() { 
pinMode(13, OUTPUT); 
pinMode(12, OUTPUT); 
}
void loop() { 
digitalWrite(13, HIGH); 
digitalWrite(12, LOW); 
delay(500); 
digitalWrite(13, LOW); 
digitalWrite(12, HIGH); 
delay(500); 
}

Troubleshooting Common Issues

LED Not Blinking

  • Check the wiring for loose connections.
  • Ensure the LED’s polarity is correct (longer leg to digital pin).
  • Verify that your code is uploaded without errors.

Arduino Not Detected

  • Confirm that the USB cable is securely connected.
  • Select the correct port in the Arduino IDE.

Enhancing Your Project

Using a Button for Manual Control

You can add a push button to control when the LED blinks. This introduces the concept of input in Arduino.

Changing LED Colors

Swap out the LED for a different color to make your project visually appealing.

Programming Patterns

Experiment with various blinking patterns, such as SOS or random intervals.

Why Start with an LED Blinking Project?

This project is a gateway to learning Arduino. It’s simple, engaging, and provides instant feedback. Plus, it lays the groundwork for more complex projects like sensors, motors, and IoT devices.

Conclusion

Congratulations! You’ve successfully completed your first Arduino LED blinking project. This beginner‑friendly project introduces coding, circuitry, and microcontroller basics. Keep experimenting and expanding your knowledgeyou’re on your way to mastering Arduino!

See also
Arduino data logging to SD card

Blinking an LED Without delay()

The code above uses delay(), which is the simplest way to blink an LED. The drawback is that delay() stops the whole program while it waits. If you later add a button or a sensor, the Arduino will not notice anything during those pauses. For a basic blink this does not matter, but it is worth knowing the alternative early.

The usual fix is to use millis(), a function that returns the number of milliseconds since the board started running. Instead of waiting, the sketch checks the clock on every pass through loop() and only changes the LED when enough time has passed.

  1. Create a variable to store the time of the last change, declared as unsigned long.
  2. Create a variable for the interval, for example 1000 for one second.
  3. At the start of loop(), read the current time with millis().
  4. If the current time minus the stored time is at least the interval, flip the LED state and save the current time as the new stored time.
  5. Write the LED state to the pin with digitalWrite().

Because nothing blocks the loop, you can add other code after these steps, such as reading a button, and the LED keeps blinking at the same pace.

A Note on Pin 13 and LED_BUILTIN

On an Arduino Uno, pin 13 is also connected to a small onboard LED. That is why the Blink example works with nothing attached, and why the onboard LED flashes in step with your external LED in this project. If you use a different board, the onboard LED may sit on another pin. Writing LED_BUILTIN instead of 13 in your code lets the IDE pick the correct pin for the board you have selected.

If you want only your external LED to blink and not the onboard one, move the jumper wire to another digital pin, such as pin 8, and change the pin number in both pinMode() and digitalWrite().

The Ultimate Money-Saving DIY Skill

From power tools and solar banks to your car, batteries are the most expensive part of your gear. Master the step-by-step DIY system to bring dead batteries back to life.

Get the Step-by-Step Guide
See also
How to Use Arduino Voltage Sensors for Your Projects

Revive Your Dead Electronics

Got a drawer full of dead gadgets or a failing car battery? Instead of paying a premium for replacements, use this simple trick to easily recondition them right from home.

See How It Works