Teresa National High School Robotics Training Sept.
9-10,2024
### **1. Blinking LED**
**Materials:**
- 1 x Arduino Uno
- 1 x LED
- 1 x 220Ω resistor
- Breadboard
- Jumper wires
**Code:**
int ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as an output
}
void loop() {
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
}
### **2. Traffic Light Controller**
**Materials:**
- 1 x Arduino Uno
- 1 x Red LED
- 1 x Yellow LED
Teresa National High School Robotics Training Sept.9-10,2024
- 1 x Green LED
- 3 x 220Ω resistors
- Breadboard
- Jumper wires
**Code:**
int redPin = 13;
int yellowPin = 12;
int greenPin = 11;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
digitalWrite(greenPin, HIGH); // Green on
delay(5000); // Wait 5 seconds
digitalWrite(greenPin, LOW); // Green off
digitalWrite(yellowPin, HIGH); // Yellow on
delay(2000); // Wait 2 seconds
digitalWrite(yellowPin, LOW); // Yellow off
digitalWrite(redPin, HIGH); // Red on
delay(5000); // Wait 5 seconds
digitalWrite(redPin, LOW); // Red off
}
Teresa National High School Robotics Training Sept.9-10,2024
### **3. Temperature Sensor**
**Materials:**
- 1 x Arduino Uno
- 1 x LM35 temperature sensor
- Breadboard
- Jumper wires
**Code:**
int tempPin = A0; // Connect LM35 to analog pin A0
void setup() {
Serial.begin(9600); // Start serial communication
}
void loop() {
int tempReading = analogRead(tempPin); // Read sensor value
float voltage = tempReading * (5.0 / 1023.0); // Convert reading to voltage
float temperature = voltage * 100; // Convert voltage to temperature (Celsius)
Serial.println(temperature); // Print temperature to serial monitor
delay(1000); // Update every 1 second
}
### **4. Ultrasonic Distance Sensor**
**Materials:**
- 1 x Arduino Uno
Teresa National High School Robotics Training Sept.9-10,2024
- 1 x HC-SR04 Ultrasonic Sensor
- Breadboard
- Jumper wires
**Code:**
const int trigPin = 9;
const int echoPin = 10;
void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
long duration;
int distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
Teresa National High School Robotics Training Sept.9-10,2024
distance = duration * 0.034 / 2; // Convert duration to distance (cm)
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(1000);
}
### **5. Sound Activated Lights**
**Materials:**
- 1 x Arduino Uno
- 1 x Microphone sensor
- 1 x LED
- 1 x 220Ω resistor
- Breadboard
- Jumper wires
**Code:**
int ledPin = 13;
int micPin = A0;
int threshold = 400;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
Teresa National High School Robotics Training Sept.9-10,2024
}
void loop() {
int soundLevel = analogRead(micPin); // Read microphone input
Serial.println(soundLevel);
if (soundLevel > threshold) {
digitalWrite(ledPin, HIGH); // Turn LED on if sound exceeds threshold
} else {
digitalWrite(ledPin, LOW); // Turn LED off if sound is below threshold
}
delay(100);
}
Each project includes simple components and foundational Arduino concepts. With explanations of code and
components, these projects will make a great start for beginners!