I am trying to write a code where photoresistors (a or b) sense blinking of the light, and lights LED (k and d) simultaneosly with that blinking. And I want that when both photoresistors sense dark for more than 3 secs, the LEDs would light up and stay until one of them again gets lighting. But I cannot understand in which part should I put millis time count?
int k = 2;
int d = 3;
int fk = A0;
int fd = A1;
int a = 0;
int b = 0;
void setup() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
Serial.begin(9600);
}
void loop()
{
a = analogRead (fk);
b = analogRead (fd);
while (a < 1000 && b < 1000)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
a = analogRead (fk);
b = analogRead (fd);
}
if (a > 1000)
digitalWrite(2, HIGH);
else
digitalWrite(2, LOW);
if (b > 1000)
digitalWrite(3, HIGH);
else
digitalWrite(3, LOW);
}