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 10 '26
You certainly.could have a loop where you analogread the pin (assuming it has an ADC capability) and Serial.println the value.
This is a good debugging technique as well as a great way to get a feel for what is going on when experimenting with different things such as a voltage divider.
If you are interested, I have prepared a how to guide that explains debugging:
They teach basic debugging using a follow along project. The material and project is the same, only the format is different.