Welcome to the World of Arduino!
If you're brand new to electronics and microcontrollers, the "Blink" sketch is your "Hello World" moment. This simple project teaches you how to upload code to an Arduino board and control an LED. It sounds basic, but you're learning fundamental concepts that apply to robots, home automation, and IoT devices.
Difficulty Level
Beginner - Perfect for your very first Arduino project
Time Required
15-30 minutes (including software setup)
What You'll Learn
- How to connect an Arduino to your computer
- How to upload code (called a "sketch" in Arduino-speak)
- How to control digital outputs
- Basic circuit building on a breadboard
Materials Needed
- Arduino Uno (or compatible board like Elegoo, SainSmart) - $20-25
- USB cable (usually included with Arduino)
- LED (any color) - comes in most Arduino starter kits
- 220Ω resistor (red-red-brown colored bands)
- Breadboard - for building circuits without soldering
- 2 jumper wires (male-to-male)
Don't Have Parts Yet?
Most Arduino boards have a built-in LED (usually connected to pin 13), so you can actually do this project with JUST the Arduino and USB cable. We'll show you both methods.
Software Setup (First Time Only)
Step 1: Download Arduino IDE
Go to arduino.cc/en/software and download the Arduino IDE (Integrated Development Environment) for your operating system. It's free and open-source.
Step 2: Install the Software
Run the installer. On Windows, it may ask to install USB drivers - say yes. This lets your computer talk to the Arduino board.
Step 3: Connect Your Arduino
Plug your Arduino into your computer using the USB cable. You should see a small LED on the board light up (this is the power indicator).
Step 4: Select Your Board
In the Arduino IDE, go to Tools → Board → Arduino AVR Boards → Arduino Uno (or whatever board you have).
Step 5: Select the Port
Go to Tools → Port and select the port with your Arduino. On Windows it's usually COM3 or COM4. On Mac/Linux, it looks like /dev/ttyUSB0 or similar.
Method 1: Using the Built-In LED (No Extra Parts)
Step 1: Open the Blink Example
In Arduino IDE: File → Examples → 01.Basics → Blink
A new window opens with the Blink code already written for you. This is your first Arduino sketch!
Step 2: Understand the Code (Optional but Helpful)
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Set pin 13 as an output
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // Turn LED on
delay(1000); // Wait 1 second
digitalWrite(LED_BUILTIN, LOW); // Turn LED off
delay(1000); // Wait 1 second
}
Breaking it down:
setup()runs once when you power on the Arduinoloop()runs over and over foreverpinModetells the Arduino whether a pin is an input or outputdigitalWriteturns a pin on (HIGH) or off (LOW)delay(1000)pauses for 1000 milliseconds (1 second)
Step 3: Upload the Code
Click the right-arrow button (→) at the top of the IDE, or go to Sketch → Upload.
You'll see "Compiling sketch..." then "Uploading..." at the bottom. Two LEDs on the Arduino (labeled TX and RX) will flash rapidly during upload.
Step 4: Watch It Blink!
After upload completes, look for a small LED on your Arduino board (usually orange/yellow). It should be blinking on for 1 second, off for 1 second, repeating forever.
🎉 Congratulations! You've programmed your first microcontroller!
Method 2: External LED on a Breadboard
Why Add an External LED?
Using a breadboard teaches you how to build circuits - a critical skill for any electronics project. Plus, you get to choose the LED color!
Step 1: Understand LED Polarity
LEDs only work in one direction. The long leg is positive (+) and goes to the Arduino pin. The short leg is negative (-) and goes to ground (GND). If your LED doesn't light up later, just flip it around.
Step 2: Build the Circuit
- Insert the LED into your breadboard - any two holes in the same row
- Connect a jumper wire from Arduino pin 13 to the LED's long leg (or the hole next to it)
- Insert one leg of the 220Ω resistor into the hole next to the LED's short leg
- Connect a jumper wire from the resistor's other leg to Arduino GND pin
Why the resistor? LEDs will burn out if you give them too much current. The resistor limits current to a safe level. Think of it like a speed bump for electricity.
Step 3: Modify the Code (Optional)
The built-in Blink example already uses pin 13, so the code works as-is! But you can change LED_BUILTIN to 13 to be more explicit:
pinMode(13, OUTPUT); digitalWrite(13, HIGH); digitalWrite(13, LOW);
Step 4: Upload and Test
Upload the sketch again. Now your external LED should blink along with the built-in LED!
Experiments to Try
Now that you've got the basics, modify the code to learn more:
Experiment 1: Change the Blink Speed
Change delay(1000) to delay(500) for faster blinking, or delay(2000) for slower. What happens with delay(100)?
Experiment 2: Morse Code SOS
SOS in Morse code is three short, three long, three short. Modify your code to blink this pattern:
// S = three short blinks digitalWrite(13, HIGH); delay(200); digitalWrite(13, LOW); delay(200); digitalWrite(13, HIGH); delay(200); digitalWrite(13, LOW); delay(200); digitalWrite(13, HIGH); delay(200); digitalWrite(13, LOW); delay(500); // O = three long blinks digitalWrite(13, HIGH); delay(600); digitalWrite(13, LOW); delay(200); digitalWrite(13, HIGH); delay(600); digitalWrite(13, LOW); delay(200); digitalWrite(13, HIGH); delay(600); digitalWrite(13, LOW); delay(500); // S = three short blinks digitalWrite(13, HIGH); delay(200); digitalWrite(13, LOW); delay(200); digitalWrite(13, HIGH); delay(200); digitalWrite(13, LOW); delay(200); digitalWrite(13, HIGH); delay(200); digitalWrite(13, LOW); delay(2000);
Experiment 3: Multiple LEDs
Connect LEDs to pins 11, 12, and 13. Make them blink in sequence like Christmas lights!
Troubleshooting Common Issues
"Port already in use" error: Close other programs that might be using the serial port (other Arduino IDE windows, serial monitors).
LED doesn't blink: Check your connections. Make sure the long LED leg goes to pin 13 and short leg goes toward GND (through the resistor).
"Board not found" error: Your computer doesn't see the Arduino. Try a different USB cable, or reinstall USB drivers.
LED is very dim: You might be using a resistor that's too large (higher than 220Ω). Try a smaller value like 100Ω.
What's Next?
Now that you can control an LED, you can control anything! Next projects to try:
- Fade an LED using PWM (pulse width modulation)
- Read a button and control the LED with user input
- Add a sensor - temperature, light, or motion
- Control a servo motor to make things move
Official Arduino Documentation
This project uses the official Arduino Blink example, which is open-source and licensed under GPL. For the complete official tutorial with diagrams and additional information, visit:
Arduino Official Blink Tutorial
Arduino examples and documentation are open-source under the GNU General Public License (GPL). Modified and expanded for Mike Is Making Stuff.