void setup() {
Serial.begin(9600);
}
void loop() {
int analogValue = analogRead(A0); // Read the ADC value from the potentiometer
int mappedVoltageInt = map(analogValue, 0, 1023, 0, 500); // Map ADC value to 0-500
float voltage = mappedVoltageInt / 100.0; // Convert to float for a 0.00 to 5.00 range
float positionPercentage = (analogValue / 1023.0) * 100; // Calculate position as a percentage
Serial.print("ADC Value: ");
Serial.print(analogValue);
Serial.print(" | Voltage: ");
Serial.print(voltage, 2); // Display voltage with two decimal places
Serial.print(" V | Position: ");
Serial.print(positionPercentage, 2); // Display position with two decimal places
Serial.println(" %");
delay(500);
}