// Program: DigitalInput-E.ino
// This program sets the LED state the same as that of the button.
const int LedPin = 25; // LED connected to GPIO pin 25
const int ButtonPin = 15; // Push-button connected to GPIO pin 15
int val = 0; // Variable to store the read value
void setup() {
pinMode(LedPin, OUTPUT); // sets the digital pin 25 as
// OUTPUT
pinMode(ButtonPin, INPUT_PULLUP); // sets the digital pin 15 as
// INPUT_PULLUP
}
void loop() {
// reads the button's value via the ButtonPin input
val = digitalRead(ButtonPin);
if (val) {
digitalWrite(LedPin, LOW);
} else {
digitalWrite(LedPin, HIGH);
}
}