Pinout for Port Registers on Arduino Mega

hi there;

I got arduino mega adk and it looks like pinout for adk is different

http://forum.arduino.cc/index.php?topic=45329.0

void setup() {
  // put your setup code here, to run once:
  pinMode(5, INPUT);
  Serial.begin(115200);
}
void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("porte3: ");
  Serial.println(bitRead(PORTE, 3));
  Serial.print("digiR5: ");
  Serial.println(digitalRead(5));
}

my output is:
porte3: 0
digiR5: 1

why?

thx

You get current pin state with the PIN registers, not PORT. An input pin with nothing connected to it can read high or low at random - it's floating, so it will pick up noise from the environment like an antenna.

PORT is the OUTPUT register.

@DrAzzy I connect there 5V
@Whandall do we have a INPUT register?

PINA, PINB, ....

@Whandall can you pls put some links?

I knows about PINA, PINB but this works for uno I wasnt able to ggl input pins for mega, thx

The registers are documented in the datasheet, the mapping to pins probably in your links.

Whandall:
The registers are documented in the datasheet, the mapping to pins probably in your links.

Or look at Uno & Mega schematics on the Product page.

when Whandall gives me the answer, I dont get it. Thats why I was asking for a links, but later I did understand his answer :slight_smile:

Sorry, sometimes I seem to write too cryptical
and maybe too focused on answering (just) the question. :wink: