// Complete Instructions: https://RandomNerdTutorials.com/esp32-digital-inputs-outputs-arduino/

// set pin numbers
const int ledPin = 4;  // the number of the pushbutton pin
const int buttonPin =  5;    // the number of the LED pin

// variable for storing the pushbutton status 
int buttonState = 0;

void setup() {
  Serial.begin(115200);  
  // 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
  buttonState = digitalRead(buttonPin);
  //Serial.println(buttonState);
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH
  //delay(1000);
  if (buttonState == HIGH) {
    Serial.println("on");
    digitalWrite(ledPin, HIGH);
    } 
    else 
    {
    Serial.println("off");//delay(2000);
    // turn LED off
    digitalWrite(ledPin, LOW);
    //delay(2000);
  }
}