/* Button Turns on and off a light emitting diode(LED) connected to digital pin PA7, when pressing a pushbutton attached to pin PA3. The circuit: - ATtiny44 - LED attached from pin 6 to ground - pushbutton attached to pin 10 from +5V - 10K resistor attached to pin 10 from ground created 2005 by DojoDave modified 30 Aug 2011 by Tom Igoe modified 9 March 2021 by Jonathan León This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Button */ // constants won't change. They're used here to set pin numbers: const int buttonPin = PA3; // the number of the pushbutton pin. INPUT const int ledPin = PA7; // the number of the LED pin. OUTPUT // variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); } }