🛠 Read a potentiometer with the 14-bit ADC
Goal
Use the RA4M1 ADC, which resolves up to 14 bits (0-16383) against the AVR Uno's 10 bits, to read a potentiometer and watch it live in the Serial Plotter.
Wiring
Potentiometer: outer legs to 5 V and GND, wiper to A0. The board logic is 5 V, so a 5 V rail is fine here.
Code
void setup {
Serial.begin(115200);
analogReadResolution(14); // 0..16383 (default is lower)
}
void loop {
Serial.println(analogRead(A0));
delay(2);
}
Open the Serial Plotter and turn the knob: a smooth ramp from rail to rail. Because the ADC is much finer, small knob moves that were invisible on an R3 now show up.
Expected result
Stable values near 0 and 16383 at the extremes ; mid-turn values around 8192 with a few LSBs of noise, which is normal at this resolution.
Common mistakes
- Forgetting analogReadResolution(14): you keep the default resolution and wonder why values stop at 1023.
- Mixing up analogReadResolution and analogWriteResolution: they are separate settings.
- Probing a floating pin: expect jitter ; tie unused inputs or drive the source.
Autres tutoriels pour cette carte
Exemples de code pour cette carte
clignotante.inoArduinobouton-poussoir.inoArduinodac-analogique.inoArduinoentree-analogique.inoArduinopwm-respiration.inoArduinoservo-balayage.inoArduino