/*Potentiometer is connected
to GPIO 34 (Analog ADC1_CH6) */
const int potPin = 34;
/*variable for storing the
potentiometer value*/
int potValue = 0;
int voltage=0;
void setup() {
Serial.begin(115200);
delay(1000);
}
void loop() {
/*Reading potentiometer
value*/
potValue = analogRead(potPin);
/*5.0 tegangan yang diukur dan
4096.0 adalah resolusi ADC 12bit sehingga
1bit=0.01221V*/
float voltage = potValue * (5.0/4096.0);
//menampilkan hasil via serial
Serial.print(" Tegangan=");
Serial.print(voltage);
Serial.print("V ");
Serial.print("Potensio(ADC)=");
Serial.println(potValue);
delay(500);
}