FE Control Light Room With Arduino and PIR Motion Sensor
by 788820 in Circuits > Arduino
21 Views, 0 Favorites, 0 Comments
FE Control Light Room With Arduino and PIR Motion Sensor
Today we will be doing a tutorial on how to make a Control Light Room With Arduino and PIR Motion Sensor.
This is a very easy tutorial and anybody could do it and it will just take 5 minutes for it to be completed.
Supplies
For the supplies we are going to needing is a Arduino, PIR sensor, Lamp, Relay Module, Breadboard, Some wires and a diode
How to Put the Materials Together
we are going to be needing our Breadboard and the Arduino for the first step, including the wires. we are going to have to use the wires and connect the wires to the Arduino. Then we are going to get the Relay module and try to connect some wires to the Relay module as well.
Connecting
Now we are going to connect the PIR Sensor to the lamp and to the Breadboard. For the PIR Sensor the signal is going to connect to thermal 2 of the lamp and the we are going to connect the put a wire at the power, then we are going to connect that wire to the Breadboard. At last we are going to connect another wire to the ground and it is going to be connect the to the breadboard but it needs to be in negative area. For the lamp, thermal one is going to be ground so we connect that wire to ground.
Coding.
We are going to code because if we don't do the coding then the Lamp wouldn't turn on and there would be some errors due to no coding. The coding is the easiest part. for the we will have to use.
int lamp = 8; // choose the pin for the RELAY
int inputPin = 4; // choose the input pin (for PIR sensor)
int val = 0; // variable for reading the pin status
void setup() {
pinMode(lamp, OUTPUT); // declare lamp as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600);
}
void loop(){
val = digitalRead(inputPin); // read input value
Serial.println(val);
if( val== 1) {
digitalWrite(lamp,HIGH); // turn ON the lamp
} else {
digitalWrite(lamp,LOW); // turn OFF the lamp
}
}
Completed
the Lamp turns on and if we move the PIR sensor, the lamp turns on for a few seconds and it turns off again after but u have to move it for it to turn on and if it doesn't work for you. there is probably something wrong with the wires but overall it is very easy to do and it is also very easy to complete and it is also very good project for circuts.