Go Down

Topic: digitalread() on ports 22 - 53 (Read 828 times) previous topic - next topic

GeneX

Hi guys
I have a problem with digitalread() on arduino mega 2560

I'm using pin 24 as input and pin 22 and 23 as outputs
pin 22 is high and pin 23 is low

digitalread(24) should return 1 if I connect pin 22 and 24 with a wire but it always returns 0

here is my code

Code: [Select]


void setup()

  // Input Output Init
  pinMode(24,INPUT);          // sets the digital pin as input
  pinMode(22,OUTPUT);         // sets the digital pin as output
  pinMode(23,OUTPUT);         // sets the digital pin as output
 
  digitalWrite(22,HIGH);      // Set pin 22 high
  digitalWrite(23,LOW);       // Set pin 23 low
 
  Serial.begin(9600);
  delay(200);
  Serial.println("ready");
 
}

void loop()
{
   
    Serial.println(digitalRead(24));
    delay(500);   
}



it works fine if i use one of the pwm pins as input but i dont want to waste them for a simple bridge
so is there a way to get a HIGH with digitalread() on pin 24?

retrolefty

Works fine on my Seeeduino mega1280 board. Perhaps you have a damaged pin 24? Does pin 24 work OK as an output pin?

Lefty

GeneX

ok pin 24 is damaged

thanks retrolefty

Go Up