// This line tells the computer that we want to name D2, which is the pin we will connect our LED
// to, "LED_PIN"
#define LED_PIN PD2
// This line tells the computer that we want to name D3, which is the pin we will connect our LED
// to, "BUTTON_PIN"
#define BUTTON_PIN PD3
// Everything inside the curly braces after the word setup() is run one time
// when the computer first boots up
void setup() {
// This line tells the Arduino that it will have to send
// electricity out from the pin we connect our LED to
pinMode(LED_PIN, OUTPUT);
// This line tells the Arduino that it will have to read
// whether or not electricity is flowing through our button
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
// Everything inside the curly braces after the word loop() is repeated over
// and over again by the Arduino
void loop() {
// This line checks if the button is pushed, if it is, the computer follows the instructions
// in the code in the curly braces after "if", if it isn't, the computer follows the
// instructions in the code in the curly braces after "else"
if (!digitalRead(BUTTON_PIN)) {
// This line tells the computer to start sending electricity out to the LED to turn it on.
// It tells the Arduino to make the voltage HIGH at the pin we named LED_PIN
digitalWrite(LED_PIN, HIGH);
// This line tells the computer to wait for 0.1 seconds
delay(100);
// This line tells the computer to stop sending electricity out to the LED to turn it off.
// It tells the Arduino to make the voltage LOW at the pin we named LED_PIN
digitalWrite(LED_PIN, LOW);
// This line tells the computer to wait for 0.1 seconds
delay(100);
} else {
// This line tells the computer to start sending electricity out to the LED to turn it on.
// It tells the Arduino to make the voltage HIGH at the pin we named LED_PIN
digitalWrite(LED_PIN, HIGH);
// This line tells the computer to wait for 1 second
delay(1000);
// This line tells the computer to stop sending electricity out to the LED to turn it off.
// It tells the Arduino to make the voltage LOW at the pin we named LED_PIN
digitalWrite(LED_PIN, LOW);
// This line tells the computer to wait for 1 second
delay(1000);
}
// Here, the computer goes back at the beginning of the curly braces and does it again
}