Video
# Lab: Blinking LED
## **Objective**
Learn the basics of Arduino programming by controlling an LED connected to digital pin D3. The LED will blink (turn on and off) every 1 second.
## **Learning Outcomes**
- Understand basic Arduino programming structure
- Learn about digital output pins
- Master the **digitalWrite()** and **delay()** functions
- Understand the concept of blinking an LED
## **Required Components**
1. **Lonely Binary UNO R3** - Main Arduino board
2. **TinkerBlock UNO R3 Shield** - Expansion shield that plugs onto the UNO R3
3. **TinkerBlock TK01 - XL LED** - LED module with 4-pin connector
## **Theory**
### **What is an LED?**
A Light Emitting Diode (LED) is a semiconductor device that emits light when an electric current passes through it. LEDs are commonly used as indicators in electronic circuits.
### **Digital Output**
Arduino digital pins can be configured as either inputs or outputs. When configured as outputs, they can provide:
- **HIGH (5V)**: Turn on connected devices
- **LOW (0V)**: Turn off connected devices
### **Key Functions Used**
- **pinMode(pin, mode)**: Configures a pin as input or output
- **digitalWrite(pin, value)**: Sets a digital pin HIGH or LOW
- **delay(milliseconds)**: Pauses the program for a specified time
## **Circuit Diagram**
```
Lonely Binary UNO R3
↓
TinkerBlock UNO R3 Shield
↓
TinkerBlock TK01 - XL LED Module
```
## **Connection Instructions**

1. **Assemble the Hardware:**
- Place the TinkerBlock UNO R3 Shield onto the Lonely Binary UNO R3
- Ensure all pins are properly aligned and seated
- The shield should fit snugly on top of the Arduino board
2. **Connect the LED Module:**
- Take the TinkerBlock TK01 - XL LED module
- Align the 4-pin connector with any available 4-pin slot on the shield
- Gently push the module into the slot until it clicks into place
- The module will automatically connect:
- **GND** pin to ground
- **VCC** pin to 5V power
- **NC** pin remains unconnected
- **D3** pin to digital pin D3
3. **Important Notes:**
- No breadboard or jumper wires required
- The LED module has a built-in current limiting resistor
## **Code**
```cpp
// Lab 1: LED Blinking
// LED connected to digital pin D3
// Define the LED pin
const int ledPin = 3;
void setup() {
// Configure pin D3 as output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Turn LED on (HIGH)
digitalWrite(ledPin, HIGH);
// Wait for 1 second (1000 milliseconds)
delay(1000);
// Turn LED off (LOW)
digitalWrite(ledPin, LOW);
// Wait for 1 second (1000 milliseconds)
delay(1000);
}
```
## **Code Explanation**
### **Setup Function**
```cpp
void setup() {
pinMode(ledPin, OUTPUT);
}
```
- Runs once when Arduino starts
- Configures pin D3 as an output pin
- This tells Arduino that we want to send signals to this pin
### **Loop Function**
```cpp
void loop() {
digitalWrite(ledPin, HIGH); // Turn LED on
delay(1000); // Wait 1 second
digitalWrite(ledPin, LOW); // Turn LED off
delay(1000); // Wait 1 second
}
```
- Runs continuously after setup
- **digitalWrite(ledPin, HIGH)**: Sends 5V to pin D3, turning LED on
- **delay(1000)**: Pauses program for 1000 milliseconds (1 second)
- **digitalWrite(ledPin, LOW)**: Sends 0V to pin D3, turning LED off
- The cycle repeats, creating the blinking effect
## **Testing and Verification**
1. **Upload the code to Lonely Binary UNO R3**
2. **Observe the LED behavior:**
- The XL LED on the TK01 module should turn on for 1 second
- The LED should turn off for 1 second
- This pattern should repeat continuously
3. **Verify connections:**
- Ensure the shield is properly seated on the Arduino
- Check that the TK01 module is firmly connected to the shield
- Confirm the LED is visible and not obstructed
## **Troubleshooting**
### **LED doesn't light up:**
- Check if the TinkerBlock shield is properly seated on the Arduino
- Ensure the TK01 module is firmly connected to the shield
- Verify the module is connected to a slot that uses D3 pin
- Check if code uploaded successfully to the Lonely Binary UNO R3
### **LED stays on or off:**
- Check if **delay()** functions are working
- Verify pin number in code matches the shield's D3 connection
- Ensure the Lonely Binary UNO R3 is powered
- Try reconnecting the TK01 module to a different 4-pin slot
### **LED is dim:**
- Check power supply to the Lonely Binary UNO R3
- Ensure the shield is making good contact with all pins
- Try cleaning the module connector pins if necessary
## **Experiment Variations**
### **1. Change Blinking Speed**
Modify the delay values to change blinking speed:
```cpp
delay(500); // Blink every 0.5 seconds
delay(2000); // Blink every 2 seconds
```
### **2. Different Blinking Patterns**
Create Morse code patterns or different timing sequences:
```cpp
// Fast blink pattern
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(1000);
```
## **Questions for Understanding**
1. What is the advantage of using the TinkerBlock shield system over traditional breadboard wiring?
2. How would you make the LED blink faster?
3. What is the purpose of the **setup()** function?
4. Why do we need to use **pinMode()** in setup?
5. What does the NC (No Connection) pin on the TK01 module do?
6. How many TK01 LED modules could you connect to the shield simultaneously?
## **Next Steps**
- Try connecting multiple TK01 LED modules to different 4-pin slots on the shield
- Experiment with different blinking patterns
- Learn about analog output using **analogWrite()** for LED brightness control
- Explore other TinkerBlock modules that can be connected to the shield
- Try creating patterns with multiple LEDs using different digital pins
## **Safety Notes**
- Always disconnect power before connecting or disconnecting modules
- Handle the TinkerBlock shield and modules carefully to avoid bending pins
- Ensure proper alignment when connecting modules to prevent damage
- The built-in resistor in the TK01 module prevents LED damage
- Keep the Lonely Binary UNO R3 and shield in a stable position during operation
---
**Lab Completion Checklist:**
- [ ] TinkerBlock shield properly seated on Lonely Binary UNO R3
- [ ] TK01 LED module connected to shield
- [ ] Code uploaded successfully to Lonely Binary UNO R3
- [ ] LED blinks every 1 second
- [ ] Troubleshooting completed (if needed)
- [ ] Experiment variations tried
- [ ] Questions answered