arduino_new:
consider the following pseudo code:
I dont think I follow on this one.
I added some more to your example to try to understand it but I think it would reset "time_stamp=millis()" every time it loops?
I'm also not sure about when to set "time_stamp=0" without it looping continuously equal to 0
I'm new to programming so it could be a simple solution staring me in the face and I dont see it yet.
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
if (time_stamp == 0) {
time_stamp = millis();
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}
else {
digitalWrite(ledPin, LOW);
}
}