0

The idea is: If the door is closed, and the PIR sensor registers movement, the cat is alive. If the door stay closed, but the movement stops the cat is dead. Of course the cat can stay still, so we'll want to confirm, at least once.

Here is my approach:

while (door_state == closed) {
      PIR.read; 
      if (PIR == true) {
         activity = true;
         }
      if (activity == true && PIR == false) {
          wait(10min.)
          if (activity == true && PIR == false) {
              alarm.activate
             }
         }

Trouble is, using the wait function hogs the processor. Would a more proper scheme, be to use a explicit timer or perhaps a threaded process. ?
I'm probably going to use either a beagleboard black or a raspberry pi.

Andreas HD
  • 25
  • 4
  • So you would recommend an approach like so: https://stackoverflow.com/questions/92928/time-sleep-sleeps-thread-or-process – Andreas HD Sep 08 '17 at 09:18

1 Answers1

0

So I made a mistake - My assumption regarding processor hogging was based on my work on AVR and Cypress embedded platforms. Obviously, the scheduler handles sleeping processes, so therefore, this approach could work.

Info found in: How can I make a time delay in Python?

Andreas HD
  • 25
  • 4