Arduino analogRead Returns 1023 Always
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about Arduino analogRead Returns 1023 Always. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.
The Problem
analogRead() always returns 1023 (max value) regardless of input voltage.
Quick Fix
Wrong
int val = analogRead(A0); // A0 is floating
val == 1023 (floating pin reads HIGH).
Right
int sensorPin = A0;
void setup() {
Serial.begin(9600);
// No pinMode needed โ analog pins default to input
}
void loop() {
int val = analogRead(sensorPin);
float voltage = val * (5.0 / 1023.0);
Serial.print("ADC: ");
Serial.print(val);
Serial.print(" Voltage: ");
Serial.println(voltage);
delay(500);
}
ADC: 512 Voltage: 2.50 (varies with input).
Prevention
analogRead() returns 0-1023 (10-bit) on AVR. A floating analog pin reads random or max values. Always connect a signal source. The reference voltage is 5V by default (change with analogReference()). The ADC reading settles faster if the source impedance is under 10 kOhm.
DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.
FAQ
โ Previous
Arduino analogWrite Value Out of Range
Next โ
Arduino Setting or Clearing a Bit by Variable Position
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro