Rev 2.0.8: Bug of 'digitalRead'
Posted: 04 Mar 2017 20:11
The response of the 'digitalRead' command has changed between revision 2.0.7 and 2.0.8 (version from Feb 28, 2017). The command seems to behave incorrectly in revision 2.0.8.
Test case:
Output with revision 2.0.8:
The pin is not shorted to ground (=it is pulled up):
The pin is shorted to ground:
Test case:
- A pin (example pin 6) is configured as INPUT_PULLUP.
- Since this pin is pulled up it is expected that 'digitalRead' returns 'high' (something different than 0), which is the case with revision 2.0.7. However with 2.0.8 the command returns 0.
- If the pin is shorted to ground it is expected that 'digitalRead' returns 0, which is the case with revision 2.0.7. However with revision 2.0.8 the command returns 1.
Code: Select all
#define PIN_BUTTON1 6
void setup() {
pinMode(PIN_BUTTON1,INPUT_PULLUP); // Control button 1
Serial.begin(); // Status information reports
}
void loop() {
Serial.print("But1=");
Serial.print(digitalRead(PIN_BUTTON1));
Serial.print(", LOW=");
Serial.print(LOW);
Serial.print(", HIGH=");
Serial.print(HIGH);
Serial.println("");
Serial.flush();
delay(1000);
}
The pin is not shorted to ground (=it is pulled up):
Code: Select all
But1=0, LOW=0, HIGH=1
Code: Select all
But1=1, LOW=0, HIGH=1