# Your First Arduino Program: Blinking LED
## **Welcome to Your First Arduino Project!**
In this guide, you'll learn how to:
1. **Install Arduino IDE 2.x** (the latest version)
2. **Connect your Lonely Binary UNO R3** to your computer
3. **Select the correct board** in Arduino IDE
4. **Write your first program** to blink the built-in LED
5. **Upload and test** your code
This is the perfect starting point for anyone new to Arduino programming!
## **Step 1: Install Arduino IDE 2.x**

### **Download Arduino IDE 2.x**
1. **Go to the official Arduino website**: [arduino.cc](https://arduino.cc)
2. **Click "Software"** in the top menu
3. **Click "Arduino IDE"**
4. **Click "Download Arduino IDE"**
5. **Choose your operating system**:
- **Windows**: Download the Windows installer (.exe file)
- **macOS**: Download the macOS version (.dmg file)
- **Linux**: Download the Linux version (.tar.xz file)
### **Install Arduino IDE**
**For Windows:**
1. **Run the downloaded .exe file**
2. **Follow the installation wizard**
3. **Accept the default settings**
4. **Click "Install"**
5. **Wait for installation to complete**
**For macOS:**
1. **Open the downloaded .dmg file**
2. **Drag Arduino IDE to your Applications folder**
3. **Open Arduino IDE from Applications**
**For Linux:**
1. **Extract the .tar.xz file**
2. **Run the install.sh script**
3. **Follow the terminal instructions**
### **First Launch**
1. **Open Arduino IDE 2.x**
2. **You'll see a welcome screen**
3. **Click "Get Started"** or close the welcome screen
4. **You'll see the main Arduino IDE window**
## **Step 2: Connect Your Lonely Binary UNO R3**
### **What You Need**
- **Lonely Binary UNO R3 board**
- **USB Type-C cable**
- **Computer with USB port**
### **Connection Steps**
1. **Take your USB Type-C cable**
2. **Connect one end to your Lonely Binary UNO R3** (the USB Type-C port)
3. **Connect the other end to your computer**
4. **The board should power on** - you'll see a small green LED light up
### **What Happens When Connected**
- **Power LED**: Small green light on the board (indicates power)
- **Built-in LED**: Pin 13 LED (this is what we'll control)
- **Computer Recognition**: Your computer should detect the board
### **Troubleshooting Connection**
- **No power LED**: Check USB cable connection
- **Computer doesn't recognize board**: Try a different USB port
- **Driver issues**: Arduino IDE will help install drivers if needed
## **Step 3: Select Your Board in Arduino IDE**
### **Open Board Manager**
1. **In Arduino IDE, go to Tools - Board - Arduino AVR Boards**
2. **Look for "Arduino Uno"** in the list
3. **Click on "Arduino Uno"** to select it

### **Alternative Method**
1. **Go to Tools - Board**
2. **Scroll down to "Arduino AVR Boards"**
3. **Select "Arduino Uno"**
### **Verify Board Selection**
- **Look at the bottom of Arduino IDE**
- **You should see "Arduino Uno"** in the board selection area
- **If you see "Arduino Uno", you're ready to program!**
### **Select Serial Port**

## **Step 4: Write Your First Program**
### **Open a New Sketch**
1. **In Arduino IDE, go to File - New**
2. **You'll see a blank sketch with this basic structure**:
```cpp
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
```
### **Understanding the Code Structure**
- **setup()**: Runs once when the board starts
- **loop()**: Runs continuously, over and over again
- **//**: These are comments (notes for humans, ignored by the computer)
### **Write the Blinking LED Code**
**Replace the empty sketch with this code**:
```cpp
// Pin 13 has a built-in LED connected to it
const int ledPin = 13;
void setup() {
// Set pin 13 as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Turn the LED on (HIGH is the voltage level)
digitalWrite(ledPin, HIGH);
// Wait for 1 second (1000 milliseconds)
delay(1000);
// Turn the LED off by making the voltage LOW
digitalWrite(ledPin, LOW);
// Wait for 1 second
delay(1000);
}
```
### **Code Explanation (Simple Terms)**
- **const int ledPin = 13;**: We're giving the number 13 a name "ledPin"
- **pinMode(ledPin, OUTPUT);**: We're telling the board that pin 13 will send signals (not receive them)
- **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
- **Then the loop starts over!**
## **Step 5: Upload Your Code**
### **Save Your Sketch**
1. **Go to File - Save As**
2. **Choose a location** (like Desktop or Documents)
3. **Name it "BlinkingLED"**
4. **Click "Save"**
### **Upload to Your Board**
1. **Click the "Upload" button** (right arrow icon) in the toolbar
2. **Or go to Sketch - Upload**
3. **Watch the progress bar** at the bottom
4. **Wait for "Upload complete"** message

### **What Happens During Upload**
- **Arduino IDE compiles your code** (checks for errors)
- **Code is sent to your board** through the USB cable
- **Board restarts and runs your program**
- **Built-in LED starts blinking!**
### **Troubleshooting Upload**
- **"Board not found"**: Check USB connection and board selection
- **"Port not available"**: Select the correct port in Tools - Port
- **Compilation errors**: Check your code for typos
## **Step 6: Test Your Program**
### **What You Should See**
- **Built-in LED on pin 13 blinking**
- **1 second on, 1 second off**
- **Continuous blinking pattern**
### **If the LED Doesn't Blink**
1. **Check the upload was successful**
2. **Look for the small LED near pin 13**
3. **Make sure the board is powered**
4. **Try pressing the reset button on the board**
### **Congratulations!**
**You've just created your first Arduino program!**

## **Understanding What You Built**
### **The Blinking Pattern**
```
LED ON - Wait 1 second - LED OFF - Wait 1 second - Repeat
```
### **Why This Works**
- **Digital pins** can only be HIGH (5V) or LOW (0V)
- **HIGH** = LED on (current flows)
- **LOW** = LED off (no current)
- **delay()** pauses the program so you can see the changes
### **The Loop Concept**
- **loop() runs forever**
- **Each cycle**: ON - wait - OFF - wait
- **This creates the blinking effect**
## **Experiment and Learn**
### **Try These Modifications**
**Change the Blinking Speed**
```cpp
// Faster blinking (0.5 seconds)
delay(500); // 500 milliseconds = 0.5 seconds
// Slower blinking (2 seconds)
delay(2000); // 2000 milliseconds = 2 seconds
```
**Create Different Patterns**
```cpp
// Quick double blink
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(1000);
```
### **Common Questions**
**Q: Why does the LED blink?**
**A**: The **loop()** function runs continuously, turning the LED on and off with delays in between.
**Q: Can I change the blinking speed?**
**A**: Yes! Change the numbers in the **delay()** functions. Smaller numbers = faster blinking.
**Q: What if my LED doesn't work?**
**A**: Check your USB connection, make sure the upload was successful, and look for the small LED near pin 13.
**Q: Can I use a different pin?**
**A**: Yes! Change **ledPin = 13** to any other digital pin (2-12), but you'll need to connect an external LED.
## **Next Steps**
Now that you've mastered the blinking LED, you're ready for more exciting projects:
1. **Control multiple LEDs**
2. **Add buttons and sensors**
3. **Create different light patterns**
4. **Build interactive projects**
**You've taken your first step into the amazing world of Arduino programming!**
The blinking LED is the "Hello World" of electronics - simple but powerful. Every complex Arduino project starts with understanding these basic concepts.
**Keep experimenting, keep learning, and most importantly, have fun!**
TinkerBlock UNO R3 Starter Kit
Dive into the world of electronics, Arduino programming, and STEM projects with the Lonely Binary TinkerBlock Series Starter Kit.
- Choosing a selection results in a full page refresh.