r/ArduinoHelp • u/Embarrassed-Lab6622 • Jul 07 '26
Coding for resistor ladder input on ESP32
Hello. I am trying to write some code in Arduino that will read the input pin (D32) and based on the on the different voltage, the will different outputs and a timer. Is it as simple as:
if (SWITCH_INPUT == >3.0 && !timerActive) {
digitalWrite(HIGH_HEAT, HIGH); // Turn the seat heater on HIGH
previousMillis = millis(); // Save the starting timestamp of the timer
timerActive = true; // Flag that the timer is now active
}
Then repeat for each of the 6 positions of the input switch?
1
Upvotes
View all comments
Show parent comment
1
u/gm310509 Jul 09 '26
Yes....
Means, read the digital setting of whatever is connected to the GPIO pin
SWITCH_INPUT. The setting (HIGH or LOW) will be returned "via the function name" i.e. digitalRead and by courtesy of the=operator, that value (HIGH/LOW) will be placed into the variable namedbuttonState.That is, after executing that line, the value of the GPIO pin identified by SWITCH_INPUT will wind up being placed into buttonState. Therefore, buttonState needs to be the subject of the if statements.