Maker Pro
Maker Pro

interfacing pic16f877A with motion sensor

orient

Aug 4, 2015
2
Joined
Aug 4, 2015
Messages
2
I am working on a project that senses when a person enters a room, and then switch ON the light in the room and then switch it OFF when the person leaves.
I want to use two PIR motion sensors, one outside the room and the other inside such that when the outside sensor is triggered before the inside sensor, then the microcontroller will switch ON the light and if the inside sensor is triggered before the outside sensor then the light will be switched OFF.
I also want to count the number of persons that go into the room so that the light will only switch OFF when all the persons that entered the room has left.
I am using two buttons to mimick the two sensors in proteus and I am using mikroC compiler.
please I need help on the code that will perform this task. I'll be very grateful.
 

jayanthd

Jul 4, 2015
43
Joined
Jul 4, 2015
Messages
43
If you still need a code then I can provide you a full working code using mikroC Compiler. If would be good if you zip and post your mikroC project files and Proteus file.
 

chopnhack

Apr 28, 2014
1,574
Joined
Apr 28, 2014
Messages
1,574
I also want to count the number of persons that go into the room so that the light will only switch OFF when all the persons that entered the room has left.

An interesting project! What happens when you have more people passing the exterior than actually go into the room?
 

jayanthd

Jul 4, 2015
43
Joined
Jul 4, 2015
Messages
43
An interesting project! What happens when you have more people passing the exterior than actually go into the room?

One sensor will be outside room and another inside room. So, when person goes into the room then outside sensor triggers first and inside sensor triggers next. So, only when both sensors are triggered the counter which is used to hold the value of persons entering or leaving the room is incremented or decremented. So, if only one sensor is triggered then the counter value doesn't change.

This thing can happen, one person tries to enter the room and he triggers the outside sensor and before he enters the room a person from the room tries to get out of the room and triggers the inside sensor and this will increment the counter.
 

chopnhack

Apr 28, 2014
1,574
Joined
Apr 28, 2014
Messages
1,574
This thing can happen, one person tries to enter the room and he triggers the outside sensor and before he enters the room a person from the room tries to get out of the room and triggers the inside sensor and this will increment the counter.
Very astute! This would end up yielding false light on conditions, which could probably be taken care of with some programming to poll the interior PIR for heat and motion. If none found, lights out.
 

orient

Aug 4, 2015
2
Joined
Aug 4, 2015
Messages
2
Thanks a lot Jayanthd for your wealth of knowledge. Your observation about false light on conditions is very correct. please I will be grateful if you can assist me in the code to take care of that limitation. I attached herewith the mikroC code I have written but have not been able to take care of the false light on condition and also the proteus file. thanks a lot. I look forward to seeing your reply.
 

Attachments

  • orient_project.zip
    34.9 KB · Views: 98
Top