int x;
int y;
bool OF= 0;
int ON = HIGH;
void setup() {
pinMode(5, INPUT_PULLUP);
pinMode(2, OUTPUT);
Serial.begin(9600);
}
void loop() {
x = digitalRead(5);
y = OF ? HIGH : LOW;
if (ON == HIGH && x == LOW) {
OF = !OF;
digitalWrite(2, OF ? HIGH : LOW);
}
ON = x;