potentiometre-plotter.ino
The 10-bit converter reads the wiper from 0 to 1023; the IDE serial plotter draws the curve live. Useful for any analog sensor (LDR, TMP36, joystick).
Hardware required
An Arduino Duemilanove (ATmega168 or 328P, 16 MHz, 5 V) with its mini-USB-B cable; the serial port appears once the FTDI driver is installed. 1 10 kΩ potentiometer.
Wiring
Potentiometer ends to 5 V and GND, wiper to A0.
How it works
analogRead samples the voltage divider formed by the potentiometer; conversion is referenced to 5 V by default. In the Arduino IDE, select « Arduino Duemilanove » (or « Diecimila » for very old boards) and the FTDI port, then Upload. The ATmega168 leaves only 14 KB for the sketch.
Going further
Swap the potentiometer for an LDR + resistor for a light meter, or a TMP36 for a thermometer.
potentiometre-plotter.ino
// Lecture 10 bits d'un potentiometre sur A0, trace serie.
const int POT = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int brut = analogRead(POT); // 0..1023
float tension = brut * (5.0 / 1023.0); // vers 0..5 V
Serial.print(brut);
Serial.print('\t');
Serial.println(tension, 2);
delay(50);
}