intLEDpin=5;// LED on pin 5
intswitchPin=13;// momentary switch on 13, other side connected to ground
boolrunning=false;voidsetup(){pinMode(LEDpin,OUTPUT);pinMode(switchPin,INPUT);digitalWrite(switchPin,HIGH);// turn on pullup resistor
}voidloop(){if(digitalRead(switchPin)==LOW){// switch is pressed - pullup keeps pin high normally
delay(100);// delay to debounce switch
running=!running;// toggle running variable
digitalWrite(LEDpin,running);// indicate via LED
}}