Find both gain and offset from two Arduino ADC measurements
A meter measures 1,100 mV at ADC code 200 and 3,950 mV at code 800.
0 of 3 complete · Progress saved on this device
Work out the example
A meter measures 1,100 mV at ADC code 200 and 3,950 mV at code 800. Treat these two readings as a local linear model. The voltage difference is 2,850 mV over 600 counts.
Decide what to check next
Start from the first measured voltage and add the increment relative to code 200. Using only a scale factor through zero discards the measured offset. Recheck the prediction at a third reference voltage before using it.
Compare with the serial result
It prints 2525 from the given measurements. No voltage is measured by the sketch.
Open the exact Uno example
It prints 2525 from the given measurements. No voltage is measured by the sketch.
void setup() {
Serial.begin(9600);
const long raw = 500;
Serial.println(1100L + (raw - 200) * 2850L / 600);
}
void loop() {}Verified with [email protected] on Uno R3 (2026-12-05 UTC). This check did not use physical hardware.