I'm a student working on an Arduino light sensor for a greenhouse/terrarium. So far, the photocell is reading the light and working to turn the light on or off based on how bright the ambient light is. I tried to add JeeLib.h to replace the delay with sleepy. When I added JeeLib, it stopped working.
Here is the code being used:
#include <JeeLib.h>
ISR(WDT_vect) { Sleepy::watchdogEvent(); }
int photocell = A0 ; // Tell the Arduino which pin that the photocell is attached to
int PowerTail = 13 ; // Tell the Arduino which pin that the PowerTail is attached to
int threshold = 300 ; // set the photocell threshold at 500
void setup() {
// initialize the PowerTail as an output:
pinMode(PowerTail, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
}
void loop() {
// read the value of the photocell:
int photocellValue = analogRead(photocell);
// if the analog value is high enough, turn on the PowerTail:
if (photocellValue > threshold) {
digitalWrite( PowerTail , HIGH); //fill in with what you named where the PowerTail is attached
for (byte i = 0; i < 120; ++i)
Sleepy::loseSomeTime(60000);
} else {
digitalWrite(PowerTail, LOW); //fill in with what you named where the PowerTail is attached
}
// print the photocell value:
Serial.println(photocellValue);
delay(1); // delay in between reads for stability
}
Why doesn't it work when JeeLib is added? I want to run it from batteries, but not waste batteries every day or two.