1.

Can the analogRead() function be used as a replacement for the digitalRead() function?(a) No, it cannot be used(b) Yes, it can be used but only on certain Arduino Boards(c) Yes, it can be used(d) Yes, it can be used but only for certain pinsI had been asked this question during an internship interview.Origin of the question is Digital Input Output in section Arduino Programming of Arduino

Answer»

The CORRECT choice is (c) Yes, it can be used

Easy explanation: The digitalRead() FUNCTION basically READS voltage differences of 0V and 5V which correspond to 0 and 1023, in the ArduinoEcosystem. This can be recreated using the analogRead() function to CHECK whether there is a voltage across the pin that CORRESPONDS to 0 and 1023 on the Arduino.



Discussion

No Comment Found

Related InterviewSolutions