const int Sw1 = 2;
const int Led1 = 9;
boolean lastState;
boolean reading;
boolean state = LOW;
void setup()
{
pinMode(Sw1, INPUT);
pinMode(Led1, OUTPUT);
}
void loop()
{
reading = digitalRead(Sw1);
if (reading == LOW && lastState == HIGH){
delay(10);
if (digitalRead(Sw1) == LOW) state = !state;
}
digitalWrite(Led1, state);
lastState = reading;
}