1void setup() {
2 pinMode(13, OUTPUT); // sets the digital pin 13 as output
3}
4
5void loop() {
6 digitalWrite(13, HIGH); // sets the digital pin 13 on
7 delay(1000); // waits for a second
8 digitalWrite(13, LOW); // sets the digital pin 13 off
9 delay(1000); // waits for a second
10}
1int ledPin = 13; // LED connected to digital pin 13
2int inPin = 7; // pushbutton connected to digital pin 7
3int val = 0; // variable to store the read value
4
5void setup() {
6 pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
7 pinMode(inPin, INPUT); // sets the digital pin 7 as input
8}
9
10void loop() {
11 val = digitalRead(inPin); // read the input pin
12 digitalWrite(ledPin, val); // sets the LED to the button's value
13}