look this over
const byte PinLed = 13;
const byte PinBut = A0;
byte butState;
boolean run;
const unsigned long OneSec = 1000;
unsigned long msec0;
void loop () {
unsigned long msec = millis ();
if (run && msec - msec0 >= OneSec) {
msec0 = msec;
digitalWrite (PinLed, ! digitalRead (PinLed));
Serial.println ("run");
}
byte but = digitalRead (PinBut);
if (butState != but) { // changed
butState = but;
delay (20); // debounce
if (LOW == but) // pressed
run = ! run;
}
}
void setup ()
{
Serial.begin (9600);
pinMode (PinLed, OUTPUT);
pinMode (PinBut, INPUT_PULLUP);
butState = digitalRead (PinBut);
}