// định nghĩa chân kết nối ADC
const int potPin = 34;
const int V_REF = 3.3; // define điện áp tham chiếu
// giá trị ADC đo được
int potValue = 0;
// giá điện áp và điện trở đo được
float voltage;
float resistance;
void setup() {
Serial.begin(115200);
delay(1000);
}
void loop() {
// Đọc giá trị analog
potValue = analogRead(potPin);
Serial.println(potValue);
voltage = (potValue*V_REF)/4095.0;
resistance = (potValue*5000)/4095.0;
Serial.print("ADC Value: ");
Serial.println(potValue);
Serial.print("Voltage: ");
Serial.println(voltage);
Serial.print("Resistance: ");
Serial.println(resistance);
delay(500);
}