long randNumber;
long time;
void setup() {
//start serial connection
Serial.begin(9600);
//configure pin 2 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP);
pinMode(8, OUTPUT);
Serial.println("To Onoma Sas");
randomSeed(analogRead(0));
randNumber=random(3000,5000);
Serial.println(randNumber);
digitalWrite(8, HIGH);
delay(randNumber);
time = millis();
}
void loop() {
//read the pushbutton value into a variable
int sensorVal = digitalRead(2);
if (sensorVal == HIGH) {
digitalWrite(8, LOW);
} else {
digitalWrite(8, HIGH);
Serial.println(millis()-time);
delay(2000);
}
}