// Complete Instructions: https://RandomNerdTutorials.com/esp32-digital-inputs-outputs-arduino/
// set pin numbers
const int sensorPin = 33; // the number of the pushbutton pin
// the number of the LED pin
// variable for storing the pushbutton status
int sensorState = 0;
void setup()
{
Serial.begin(115200);
// initialize the pushbutton pin as an input
pinMode(sensorPin, INPUT);
// initialize the LED pin as an output
}
void loop()
{
// read the state of the pushbutton value
sensorState = analogRead(sensorPin);
Serial.println(sensorState);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH
if (sensorState == HIGH )
{
Serial.println("DARK");
// turn LED on
delay(1000);
}
else
{
Serial.println("BRIGHT");
// turn LED off
delay(1000);
}
}