WORKING
Components used for this project are PIR
Sensor, Hall effect sensor, Arduino (ATMEGA328) Controller, Relay, Power
Supply.
P I R
sensor s allow you to sense motion , almost always
used to detect whether a human
has moved in or out
of the sensors range.
They are small , in
expensive, low- power , easy to use and don't wear out.
For that reason
they are commonly found in
appliances and gadgets used in
homes or
businesses . They are often referred
to as P I R, "Passive
Infrared", "Pyroelectric", or
"IR motion " sensors.
A Hall
effect sensor is a transducer
that varies its output voltage in
response to a magnetic field.Hall effect sensors
are used for proximity switching,
positioning, speed detection, and current sensing applications.
In
its simplest form, the sensor operates as analog transducer, directly returning a
voltage. With a known magnetic field, its distance from the Hall plate can be
determined. Using groups of sensors, the relative position of the magnet can be
deduced.
When door is opened or closed Hall
effect sensor is activated and controller switches the relay correspondingly.
After 2 seconds PIR sensor is activated and it checks for any motion inside the
room. If there is motion then bulb is switched on and will be switched off when
there is no motion.
CIRCUIT
PROGRAM
void setup()
{
pinMode(13,OUTPUT);
pinMode(5,INPUT_PULLUP);//hal
pinMode(6,INPUT);//pir
}
void loop()
{
if((digitalRead(5)==0)&&(digitalRead(6)==1))
{
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
}
else if (digitalRead(5)==1){ digitalWrite(13,HIGH); delay(1000);}
else;
}