Function
Project Overview: In this experiment, we build a “Sunlight-Activated Alarm.” Instead of setting a fixed time, this alarm relies on environmental sensors. It demonstrates how street lights or automatic brightness systems work in the real world.
Key Features:
- Automatic Detection: Uses an LDR Sensor to distinguish between Day and Night.
- Smart Logic: The Arduino constantly reads light levels. If the light value crosses a specific threshold (Morning), it triggers the alarm.
- Output: A rhythmic Beep (Buzzer) and Blink (LED) pattern indicates morning has arrived
What You Need for This Project
To build this Automatic Morning Wake-up Alarm With Sound And Light, we used the following parts from the Robots 2030 Basic Robotic Kits:
- Arduino Uno
- BreadBoard
- LDR (Light Sensor)
- Buzzer (For Sound)
- LED (Koi bhi rang)
- Resistor Blue (LED ke liye)
- Jumper Wires
Wiring (Taarein Jorna)
1. BreadBoard:
- + Connect with GND
- – Connect with A0
2. LDR Sensor:
- LDR Leg 1: Breadboard +.
- LDR Leg 2: Breadboard –.
3. LED Connections:
- LED Long Leg (+): Arduino Pin 13
- LED Short Leg (-): Blue Resistor ki aik side ke sath jorien.
- Blue Resistor doosri side: Breadboard +
4. Buzzer Wiring
- Buzzer Long Leg (+): Arduino Pin 10.
Buzzer Short Leg (-): Breadboard +
Code
int ldrPin = A0; // LDR Pin
int buzzerPin = 10; // Buzzer Pin
int ledPin = 13; // LED Pin
int lightValue = 0;
// Threshold ko adjust karein.
// Internal Pullup mein: KAM number = ROSHNI, ZYADA number = ANDHERA
int threshold = 300;
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
// YEH LINE BOHAT ZAROORI HAI (LDR ke liye internal resistor ON karti hai)
pinMode(ldrPin, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
lightValue = analogRead(ldrPin);
Serial.print("Sensor Value: ");
Serial.println(lightValue);
// Agar Roshni hai (Value 300 se kam hai)
if (lightValue < threshold) {
Serial.println("Subah Ho Gayi! Alarm Baj Raha Hai");
// Alarm ON
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
delay(200);
// Alarm OFF (Blink effect)
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
delay(200);
}
else {
// Andhera hai (Sab band)
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
}
delay(100);
}