I am trying to set a time value to 0 when I press a button so it tracks how long from 1 press to the other.
int button = 0;
int buttonstate = 0;
unsigned long time;
void setup() {
// put your setup code here, to run once:
pinMode(button, INPUT);
Serial.begin(9600);
}
void loop() {
buttonstate = digitalRead(button);
Serial.print("time: ");
time = millis();
if(buttonstate == HIGH){
unsigned long time = 0;
Serial.print(time);
}
delay(1000);
}