Experiment Name
Alarm Using an LDR (photoresistor)
Basic Overview of Experiment:
Those who are interested in learning more about this experiment are informed that this project is an alarm that operates when the photoresistor detects light. As soon as light is detected, the buzzer begins to buzz and the LED begins to blink. An Arduino IDE asset, the serial monitor, will then display a notification. A special thanks to Instructables .com for inspiring this project.
Components Required
Important Components/Algorithms
Despite not mentioning this frequently, the alarm needs to be equipped with a buzzer. You will also require Arduino IDE, which you can download by clicking here if you do not already have it. Using the appropriate resistors is one of the most important steps. A project cannot be successfully completed if the resistors are selected incorrectly.
Experiment Setup, Steps
Buzzer attach to board (the buzzer long leg (+) and short leg (-))
LED attach to board (the LED long leg (+) and short leg (-))
220 resistor attach to board from LED long leg (+)
LDR attach to board
10k resistor attach to board from LDR one leg
The wire connect to ground, then the same wire attach to board.
The wire connect to buzzer short leg, then the same wire attach to GND on the board.
The wire attach to LED short leg, then the same wire connect to GND on the board.
The wire connect to 10k resistor empty leg, then the same wire connect to GND on the board.
The wire connect to +5V, then the same wire attach to LDR empty leg.
The wire connect to digital 12, then attach to buzzer long leg.
The wire connect to digital 13, then attach to 220 resistor empty leg.
The wire connect to A0, then attach to LDR's - resistor's same column.
Source Code
const int ledPin = 13;
const int buzzerPin = 12;
const int ldrPin = A0;
void setup () {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ldrPin, INPUT);
}
void loop() {
int ldrStatus = analogRead(ldrPin);
if (ldrStatus >= 400) {
tone(buzzerPin, 100);
digitalWrite(ledPin, HIGH);
delay(100);
noTone(buzzerPin);
digitalWrite(ledPin, LOW);
delay(100);
Serial.println("alarm is on");
}
else {
noTone(buzzerPin);
digitalWrite(ledPin, LOW);
Serial.println("alarm is off");
}
}
Code inspired By (instructables.com)
Video and Pictures
If you want a project demonstration, view it on youtube.
By: Deenadarrshan Sathiyamoorthi
Comments
Post a Comment