I have a Arduino Uno, with a SparkFun PIR sensor attached on PIN 2.
I set up the PIR so its working correctly and it detects motion on LOW, but when I put the Arduino to Sleep sleep.sleepInterrupt(0,LOW); it never wakes up...
Whats wrong with this picture? The PIR works flawlessly on its own...
I basically want to save as muh power consumption as possible until the PIR says ... something moved... wake up and do something!
Thanks in advance!
#include <Sleep_n0m1.h>
Sleep sleep;
// Pin for PIR sensor
int alarmPin = 2;
int alarmValue = 0;
void setup()
{
Serial.begin(9600);
// Set up PIR PIN and give 2 seconds for it to take a room snapshot
pinMode(alarmPin, INPUT);
// turn on internal pull-up resistor
digitalWrite(alarmPin, HIGH);
delay (2000);
}
void loop()
{
delay(500);
alarmValue = digitalRead(alarmPin);
if (alarmValue == LOW)
{
Serial.println("Motion Detected");
}
delay(100); ////delays are just for serial print, without serial they can be removed
Serial.println("execute your code here");
Serial.print("Sleeping Till Interrupt");
delay(100); //delay to allow serial to fully print before sleep
sleep.pwrDownMode(); //set sleep mode
sleep.sleepInterrupt(0,LOW); //sleep for: sleepTime
}