I am trying to read the value of an output pin. online forums say that digitalRead(pinNum);
should work, but that is not the case here. digitalRead always returns 0 (LOW).
This is the code:
int pin = 22; // or 13, or 3 ...
void setup()
{
Serial.begin(9600);
pinMode(pin,OUTPUT);
}
void loop()
{
digitalWrite(pin,HIGH);
delay(100);
Serial.println(digitalRead(pin));
delay(100);
digitalWrite(pin,LOW);
delay(100);
Serial.println(digitalRead(pin));
delay(100);
}
printed values:
0
0
0
...