Да, действительно был косяк. Вот, исправил код и добавил вывод в монитор порта
int ledPin = 7;
int photoPin = A0;
long previousMillis = 0;
long interval = 5000;
unsigned long currentMillis;
long prevMillis;
int start = 0;
int led = 1;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(photoPin, INPUT);
}
void loop() {
// Serial.println(analogRead (photoPin));
if (analogRead (photoPin) > 800 && led == 1) {
start = 1;
previousMillis = millis();
prevMillis = previousMillis;
led = 0;
digitalWrite (ledPin, HIGH);
Serial.print("start "); Serial.println(millis());
}
if (start == 1) currentMillis = millis();
if (currentMillis - previousMillis >= interval ) {
previousMillis = millis();
Serial.print("stop "); Serial.print(millis()); Serial.print(" "); Serial.println(previousMillis - prevMillis);
digitalWrite (ledPin, LOW);
start = 0;
led = 0;
}
if (analogRead (photoPin) < 800) led = 1;
}