What is the output of the program given below if a 0V is put across pin 11? [code] int pin=11; void setup() { pinMode(pin, INPUT_PULLUP);

What is the output of the program given below if a 0V is put across pin 11?
Code:
int pin=11;
void setup() {
    pinMode(pin, INPUT_PULLUP);
    Serial.begin(9600);
}
void loop() {
    int a=digitalRead(pin);
    Serial.println(a);
}
A. 1
B. 0
C. 0.3
D. 1.001
 
Answer: A
Explanation: The reading across the pin would be given as 1 (digital HIGH) since the pinMode is set to INPUT_PULLUP which basically pulls the reading up to the maximum when there is no voltage applied across the pin, but functions as a normal input pin for reading voltage levels when some amount of voltage is applied across it.
 

Tìm kiếm

Back
Top