int ledpin =13; // Define pin 13 for LED
int inpin= 5; // Define pin 5 for Push Button
int val; // Define the variable val
void setup() {
pinMode(ledpin, OUTPUT); // Define LED as Output
pinMode(inpin,INPUT); // Define Button as Input
}
void loop() {
val = digitalRead(inpin); // Read digital pin 5 level value assigned to val
if(val == HIGH) // Test button is pressed
{
digitalWrite(ledpin, HIGH);
}
else {
digitalWrite(ledpin,LOW);
}
}