// Example code when button input uses pull up resistor
// Set the output pin for the LED to pin 13,
// and the input pin for the button to pin 8
int ledPin = 13;
int buttonPin = 8;
// The button can have to states, either it is pressed (LOW)
// or not pressed (HIGH)
int buttonState = 0;
// The setup function runs as soon as the Arduino gets
// connected to power
void setup() {
// Set the LED pin as output and the button pin as
// input with a pull-up resistor
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
}
// The loop is the main loop that runs/loops as fast as
// fast possible executing all code within it
void loop() {
// Read the button pin using digital read function
// and store this value in the variable buttonState
buttonState = digitalRead(buttonPin);
// Use a if statement to check if the button is pressed
// or not. If the button is pressed the button input pin
// goes low, if the buttonState variable is low, then turn
// on the LED pin by setting it high so it becomes bright.
// If the button is not pressed, then set the LED pin
// to low.
if (buttonState == LOW) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
led1:A
led1:C
r1:1
r1:2
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r