With the following code, setting the RED_LED pin "HIGH" then performing a read on the pin causes the pin to go LOW. If the pin is already LOW, the read does not cause it to go HIGH.
Paying close attention to the LED indicates the pin is going high as indicated by a very brief, weak flash of the LED.
int state = 0;
void setup() {
Serial.begin(115200);
pinMode(RED_LED, OUTPUT);
}
void loop() {
digitalWrite(RED_LED, HIGH);
state = digitalRead(RED_LED);
Serial.print(state);
delay(500);
digitalWrite(RED_LED, LOW);
state = digitalRead(RED_LED);
Serial.println(state);
delay(500);
}
From @abecedarian01 on March 8, 2016 20:40
From 43oh.com topic: http://forum.43oh.com/topic/9426-digitalread-changes-the-state-of-the-pin/#entry71321
With the following code, setting the RED_LED pin "HIGH" then performing a read on the pin causes the pin to go LOW. If the pin is already LOW, the read does not cause it to go HIGH.
Paying close attention to the LED indicates the pin is going high as indicated by a very brief, weak flash of the LED.
Copied from original issue: energia/Energia#860