#define LED 2
#define LED_out 5
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 15; // the number of the pushbutton pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
// initialize the LEDs pin as an output:
pinMode(LED, OUTPUT);
pinMode(LED_out, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is LOW:
if (buttonState == HIGH) {
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(LED_out, LOW); // turn the LED off by making the voltage LOW
} else { // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
digitalWrite(LED_out, HIGH); // turn the LED on (HIGH is the voltage level)
Serial.println("Button pressed!");
}
delay(100); //what happen if I comment this line OUT?
}