What is the output of the program given below if a voltage of 5V is supplied to the pin corresponding to the A0 pin on an Arduino UNO? [code] vo

Như Quỳnh

New member
What is the output of the program given below if a voltage of 5V is supplied to the pin corresponding to the A0 pin on an Arduino UNO?
Code:
void setup() {
    Serial.begin(9600);
    pinMode(A0, INPUT);
}
void loop() { 
    int s = analogRead(A0);
    Serial.println(s);
}
A. null
B. Error
C. 0
D. 1024
 
Answer: D
Explanation: The Arduino UNO’s analog pins map the value of the sensed voltage to an internal numbering scale which makes it easier for the programmer to work since it is more difficult to analog voltage levels in programming practice. Thus, for a value of 5V, which reaches the maximum limit, we get a value of 1024.
 

Tìm kiếm

Back
Top