I'm trying to write a program that uses a photoresistor to time how long a light is on. I've tried 2 programs, one with the sectimer library:
#include <secTimer.h>
int lightPin = 0;
secTimer myTimer;
void setup() {
Serial.begin(9600); //Begin serial communcation
myTimer.startTimer(); //start the timer
}
void loop() {
int test = analogRead(lightPin);
if (int test = 0); {
myTimer.stopTimer();
}
}
And one with the millis() command:
int lightPin = 0;
bool Light = true;
void setup() {
Serial.begin(9600); //Begin serial communcation
Serial.println(millis());
}
void loop() {
while (bool Light = true); {
delay(50);
Serial.println(millis());
int test = (analogRead(lightPin));
if (int test = 5){
bool Light = false;
}
}
}
They still don't work
The sectimer one only displays zeros, and the millis() one never seems to print the end time. Any suggestions of how I could get them to work?