What is the purpose of the code given below? [code] int pin=11; void setup() { pinMode(pin, INPUT); Serial.begin(9600); } void

What is the purpose of the code given below?
Code:
int pin=11;
void setup() {
    pinMode(pin, INPUT);
    Serial.begin(9600);
}
void loop() {
    int a=1023-analogRead(pin);
    Serial.println(a);
}
A. To demonstrate the working of the INPUT_PULLUP argument
B. To emulate the working of the OUTPUT argument
C. To emulate the analogRead method
D. To reset all input to 0
 
Answer: A
Explanation: The code given above inverts whatever voltage reading we get from the pin by subtracting the value that is acquired from the analogRead() method, from 1023, which corresponds to the maximum voltage that can be detected at the port.
 

Tìm kiếm

Back
Top