#define LED 9 //the pin for the LED #define BUTTON 7 //the input pin where the push button is connected int val = 0; //integer variable "val" used to store the state of the input (button) pin void setup() { //setup() is called once //pinMode() function configures a pin as either an input or an output pinMode(LED, OUTPUT); //tell Arduino LED is an output - the "load" of the circuit pinMode(BUTTON, INPUT); //tell Arduino BUTTON is the input } void loop() { //loop() is called over and over val = digitalRead(BUTTON); //read input value and store it //check whether the input is HIGH (button pressed) if (val == HIGH) { //digitalWrite() functions outputs a value on a pin digitalWrite(LED, HIGH); //turn LED on or high or 5 volts } else { digitalWrite(LED, LOW); //otherwise turn LED off or low or 0 volts or ground } }