// void setup() {
// pinMode(2, OUTPUT); // Initialize the LED pin as an output
// pinMode(4, OUTPUT);
// pinMode(5, OUTPUT);
// }
// void loop() {
// digitalWrite(5,HIGH ); // Turn the LED on
// digitalWrite(2, LOW);
// delay(1000); // Wait for 2 seconds
// digitalWrite(4, HIGH); // Turn the LED off by making the voltage LOW
// delay(1500); // Wait for 2 seconds
// digitalWrite(5, LOW);
// digitalWrite(4, LOW);;
// digitalWrite(2, HIGH);
// delay(2000);
// digitalWrite(2, LOW);
// digitalWrite(4, HIGH);
// delay(1500);
// digitalWrite(4, LOW);
// digitalWrite(5, HIGH);
// digitalWrite(5, LOW)
//
// }
const int buttonPin = 32; // the number of the pushbutton pin
const int ledPin = 2; // the number of the LED pin
int buttonState = 0; // variable for storing the pushbutton status
void setup() {
Serial.begin(115200); // activate serial monitor
// initialize the pushbutton pin as an input
pinMode(buttonPin, INPUT);
// initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the state of the pushbutton value (always 0 or 1)
buttonState = digitalRead(buttonPin);
Serial.println(buttonState); // send data to the monitor.
// 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);
}
}