const int RED=4; const int GREEN=0; const int BLUE=1; const int SENSE=3; const int threshold=4; const int rate=120; boolean dark=false; float cycle_time=float(rate)*768/3600000.0; //rate*768 is ms in rainbow, 3600000.0 is ms in hour float timeout_hours=8; //must be divided by x.0 (e.g. "1/15.0")to get accurate result if not an integer int cycles_to_run=int(timeout_hours/cycle_time)+1; int cycle_counter=0; void setup() { pinMode(RED,OUTPUT); pinMode(GREEN,OUTPUT); pinMode(BLUE,OUTPUT); changeColor(0,0,0); } void loop() { if ((analogRead(SENSE)=threshold)&&(dark)) { dark=false; cycle_counter=0; } if ((dark)&&(cycle_counter