Calibrate an Arduino potentiometer to 0–100%
Work through clipping and rescaling measured ADC endpoints, then run the matching Uno A0 sketch in Circuitera.
0 of 3 complete · Progress saved on this device
Measure before scaling
A mechanically restricted knob may move across only part of the ADC range. In this example your observed endpoints are 200 and 800. A reading of 500 lies halfway between them. The slider uses those fixed example endpoints so you can compare raw and normalized values.
Choose what to do outside the endpoints
A sample below 200 or above 800 can occur from noise or changed travel. Clip the sample to those endpoints before scaling it. This is a display normalization rule. Keep the raw reading alongside the percentage when diagnosing a sensor.
Check both endpoints in the sketch
Run the Uno with the potentiometer wiper on A0. Test below, between and above the endpoints and read both numbers. If calibrating physical hardware, record the endpoints with the device in its actual operating range. Reject a calibration where the minimum equals the maximum before applying map().
Open the exact Uno example
void setup() { Serial.begin(9600); }
void loop() {
const int raw = analogRead(A0);
const long percent = map(constrain(raw, 200, 800), 200, 800, 0, 100);
Serial.print(raw);
Serial.print(' ');
Serial.println(percent);
delay(100);
}Verified with [email protected] on Uno R3 (2026-12-05 UTC). The matching circuit passed its Uno model checks. This check did not use physical hardware.