const int POT_PIN = 13;
const int LED1_PIN = 2;
const int LED2_PIN = 21;
void setup() {
Serial.begin(115200);
pinMode(POT_PIN, INPUT);
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
}
void loop() {
int value = analogRead(POT_PIN);
int threshold = 2048; // Halfway of the 0-4095 range for the ESP32
if (value > threshold) {
digitalWrite(LED1_PIN, HIGH);
digitalWrite(LED2_PIN, LOW);
} else {
digitalWrite(LED1_PIN, LOW);
digitalWrite(LED2_PIN, HIGH);
}
Serial.println(value);
delay(10); // this speeds up the simulation
}