The analog input is read and the result is printed in the Serial Monitor. When the shaft is turned all the way in one direction, there are 0 volts going to the pin, and the input value is 0. When the shaft is turned all the way in the opposite direction, there are 5 volts going to the pin and the input value is 1023. In between, analogRead() returns a number between 0 and 1023 that is proportional to the amount of voltage being applied to the pin.
This process is the foundational Analog-to-Digital Converter (ADC) mechanism intrinsic to the Arduino's core silicon. While digital pins are binary (ON or OFF), the physical world is analog. By routing a dynamic voltage through a physical Potentiometer (Variable Resistor), the Arduino captures exactly how much voltage is present and serializes that information to the Serial Monitor as a continuous 10-bit integer sequence.

Demystifying the 10-Bit ADC Array
When a raw voltage enters an analog pin like A0, the ATmega328P processor executes the ADC natively.
- The 10-bit ADC quantizes the 0-5V range into
1024discrete mathematical steps. - If the physical knob is at
0V (GND), it outputs0. - If turned to
2.5V(half-way), the ADC returns512. - If at the maximum
5.0V, the ADC returns1023.
int sensorPin = A0; // Explicitly defining the Analog-capable hardware pin!
void setup() {
// Initiate the UART pipeline at 9600 Baud for Laptop communication
Serial.begin(9600);
}
void loop() {
// Execute the Analog-to-Digital reading cycle
int sensorValue = analogRead(sensorPin);
// Directly transmit the integer to the Serial Terminal
Serial.println(sensorValue);
delay(1); // 1 Millisecond stabilization buffer
}
Transforming Integers into Real Voltages
A raw serial number like "845" is not intuitive for measurement. To convert it back to a usable voltage, a simple mathematical transformation is applied:
float voltage = sensorValue * (5.0 / 1023.0);- This line multiplies the reading against the "Voltage per Step" ratio.
- The Serial Monitor will then display exact decimal voltages like
4.13V.
Required Hardware
- Arduino Uno/Nano (utilizing its 6 native Analog input pins
A0-A5). - Rotary Potentiometer (10K-Ohm) (functioning as a dynamic voltage divider).
- USB Data Cable (to sustain the continuous UART serial transmission stream).
- Arduino IDE Serial Monitor / Serial Plotter Tool (The
Serial Plottertransforms the integer list into a smooth graphical wave, visually representing the analog rotation).