PIR-sensor-based Electronic Device Control With Ultra-Low Standby Power Consumption
PIR-sensor-based Electronic Device Control With Ultra-Low Standby Power Consumption
Specs:
Resistance : 20K to 100K
Dark Resistance : 1M
int sensor = 2; // the pin that the state = HIGH; // update variable
sensor is atteched to state to HIGH
}
void loop(){
}
val = digitalRead(sensor); // read sensor
value }
LDR Code:
int sensorPin = A0; // select the input pin for LDR
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
void loop() {
delay(100);
Serial.println("Motion detected!");
Serial.println("Light Off!");
}
else {
digitalWrite(relay, HIGH);
Serial.println("Motion stopped!");
Serial.println("Light Off!");
Working:
PIR sensor is connected to Digital Pin and initialized as INPUT.
LDR is connected to Analog Pin and initialized as INPUT.
An LED is connected to Pin 13 and initialized as OUTPUT.
A Relay is connected to Pin 7 and is used to switch the AC Lamp.
CASE 1 : When no motion is detected => PIR is OFF => AC Lamp and LED are
in OFF state.
CASE 2 : When motion is detected => PIR is on
Ambient light not suffice => AC Lamp and LED are in ON state.
CASE 3 : When motion is detected => PIR is on
Ambient light suffice => AC Lamp and LED are in OFF state.