volatile int flag;
volatile int item;
void setup(){
flag = 0;
item = 0;
pinMode(2, INPUT);
pinMode(3, OUTPUT);
}
void loop(){
if (digitalRead(2) == 0 && flag == 0) {
flag = 1;
}
if (digitalRead(2) == 1 && flag == 1) {
flag = 0;
item = item + 1;
item = (long) (item) % (long) (2);
if (item == 1) {
digitalWrite(3,HIGH);
}
if (item == 0) {
digitalWrite(3,LOW);
}
}
}