void setup() {
// put your setup code here, to run once:
pinMode(A0, INPUT);
Serial.begin(9600);//khởi tạo giao tiếp serial với tốc độ truyền dữ liệu là 9600 baud
}
void loop() {
// put your main code here, to run repeatedly:
ADC = analogRead(A0);
float voltage = (ADC*5)/1023;
Serial.print("DIEN AP: ");
Serial.print(voltage);
Serial.println("V");
delay(1000);
}
/*
ADC sử dụng 10-bit, nghĩa là giá trị đọc tối đa của nó là 2^10 - 1 = 1023.
*/