// --- Adjustable settings ---
const int analogPin = A0; // Analog pin to read from
const float Vref = 5.0; // Reference voltage (depends on Arduino model and supply)
const int ADC_resolution = 1023; // For 10-bit ADC: 0–1023
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
int rawValue = analogRead(analogPin); // Read the analog value (0–1023)
float voltage = (rawValue * Vref) / ADC_resolution; // Convert to voltage
Serial.print("Raw ADC Value: ");
Serial.print(rawValue);
Serial.print(" --> Voltage: ");
Serial.print(voltage, 3); // Print voltage with 3 decimal places
Serial.println(" V");
delay(500); // Update every 500ms
}