Skip to main content
Tweeted twitter.com/StackArduino/status/726133942592659456
Since the arduino-due makes the difference, its name better be in the title.
Link
Makan
  • 239
  • 4
  • 14

Read OUTPUT pin value in Arduino Due

Source Link
Makan
  • 239
  • 4
  • 14

Read OUTPUT pin value

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
...