WEEK ONE: MONDAY:
1. Blink LED 2. Control LED (Traffic lights)
// Pin to which the LED is connected // Define LED pins
int ledPin = 13; // For most Arduino boards, the built-in const int redLED = 10;
LED is connected to pin 13 const int yellowLED = 9;
void setup() { const int greenLED = 8;
// Initialize the digital pin as an output void setup() {
pinMode(ledPin, OUTPUT); pinMode(redLED, OUTPUT);
}void loop() { pinMode(yellowLED, OUTPUT);
// Turn the LED on pinMode(greenLED, OUTPUT);
digitalWrite(ledPin, HIGH); Serial.begin(9600);
// Wait for 1 second }void loop() {
delay(1000); // Step 1: Red light ON for 5 seconds
// Turn the LED off digitalWrite(redLED, HIGH);
digitalWrite(ledPin, LOW); digitalWrite(yellowLED, LOW); // Ensure yellow is off
// Wait for 1 second digitalWrite(greenLED, LOW); // Ensure green is off
delay(1000); Serial.println("vehical STOP pedestr to pass ");
} delay(5000);
// Step 2: Red and Yellow lights ON simultaneously for 5
seconds
digitalWrite(yellowLED, HIGH);
Serial.println("vechicles rev the engines ");
delay(5000);
// Turn both Red and Yellow lights OFF
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
// Step 3: Green light ON for 5 seconds
digitalWrite(greenLED, HIGH);
Serial.println("Pedestrians To cross the road ");
delay(5000);
// Step 4: Green and Yellow lights ON simultaneously for
5 seconds
digitalWrite(yellowLED, HIGH);
delay(5000);
// Turn both Green and Yellow lights OFF
digitalWrite(greenLED, LOW);
digitalWrite(yellowLED, LOW);
}
.
TUESDAY: MONITOR LIGHT INTENSITY
// Pin connected to the LDR
const int ldrPin = A1; // Analog pin for LDR
const int ledPin = 13; // Digital pin for the LED
// Threshold for light intensity to turn on the LED
const int lightThreshold = 500; // Change this value to adjust the sensitivity
void setup() {
// Initialize the serial communication for debugging
Serial.begin(9600);
// Set the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read the analog value from the LDR pin (0-1023)
int lightIntensity = analogRead(ldrPin);
// Print the light intensity value to the serial monitor
Serial.print("Light Intensity: ");
Serial.println(lightIntensity);
// Check if the light intensity is above the threshold
if (lightIntensity > lightThreshold) {
digitalWrite(ledPin, HIGH); // Turn on the LED if light intensity is high
Serial.println("LED ON");
} else {
digitalWrite(ledPin, LOW); // Turn off the LED if light intensity is low
Serial.println("LED OFF");
}
// Add a small delay to prevent flooding the serial monitor
delay(3000); // Delay for 1 second (1000 milliseconds)
}
WEDNESDAY LCD DISPLAYS
1. Display: BED.TIE.EEE 2. Digital Voltmeter
ATTACH 2025 DGT Voltmeter
VOLTAGE =
#include <LiquidCrystal.h>
// Initialize the LCD (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2); // Set up the LCD's number of
columns and rows #include <LiquidCrystal.h>
lcd.setCursor(0, 0); // Move to the first line
(row 0) // Initialize LCD (RS, E, D4, D5, D6, D7)
lcd.print("BED TIE EEE"); // Print first line LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
lcd.setCursor(0, 1); // Move to the second line const int analogPin = A0; // Potentiometer input pin
(row 1) const float refVoltage = 5.0; // Arduino reference voltage
lcd.print("ATTACH 2025"); // Print second line
} void setup() {
lcd.begin(16, 2);
void loop() { lcd.print("Digital Voltmeter");
// No need to update the display continuously delay(2000);
} lcd.clear();
}
void loop() {
int analogValue = analogRead(analogPin); // Read from A0
float voltage = map(analogValue, 0, 1023, 0, 5000) / 1000.0; //
Convert to 0-5V
lcd.setCursor(0, 0);
lcd.print("DGT VOLTMETER: ");
lcd.setCursor(0, 1);
lcd.print("VOLTAGE = ");
lcd.setCursor(10, 1);
lcd.print(voltage, 2); // Display with 2 decimal places
lcd.print("V"); // Extra spaces to clear old values
delay(500); // Update every 500ms
}
THURSDAY: LM35 Temperature sensor FRIDAY: IR, PIR Sensors
Display Temp: on the LCD Motion sensors
#include <LiquidCrystal.h>
#include <LCD1602.h>
// Initialize LCD pins (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
#include <LiquidCrystal.h>
const int PIR_SENSOR = 2; // PIR sensor connected to Digital
// Initialize LCD pins (RS, E, D4, D5, D6, D7)
Pin 2
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() {
const int LM35_PIN = A0; // LM35 connected to
pinMode(PIR_SENSOR, INPUT); // Set PIR sensor as input
analog pin A0
lcd.begin(16, 2); // Initialize 16x2 LCD
lcd.print("Waiting..."); // Default message
void setup() {
}
lcd.begin(16, 2); // Initialize LCD (16x2)
lcd.print("Temp: "); // Initial text
void loop() {
}
int motionDetected = digitalRead(PIR_SENSOR); // Read PIR
sensor
void loop() {
int sensorValue = analogRead(LM35_PIN); // Read
if (motionDetected == HIGH) { // If motion is detected
analog voltage from LM35
lcd.clear();
float voltage = sensorValue * (5.0 / 1023.0); //
lcd.setCursor(0, 0);
Convert to voltage
lcd.print("Motion Detected!");
float temperature = voltage * 10; // Convert to
delay(5000); // Keep message for 5 seconds
Celsius (LM35 gives 10mV per degree)
lcd.clear();
lcd.setCursor(0, 0);
lcd.setCursor(6, 0); // Move cursor to display
lcd.print("Waiting...");
temperature
}
lcd.print(temperature);
lcd.print(" C "); // Ensure extra spaces to clear
delay(500); // Small delay to prevent flickering
previous values
}
delay(1000); // Update every second
}