MEGA1280 question

This may be a dumb question or observation but ... I an trying to read/write digital I/O on the Arduino MEGA1280 but cannot seem to read or write digital I/O above address 20.

Have I missed a compiler directive somewhere or is there an IDE setting? The IDE is set for the correct board under TOOLS.

This is something very obvious I'm sure. :-[

Should not be a problem. Just post some code that shows the problem and let us look at it.


My code simply toggles the LED and at the same time toggles the I/O port set by the int testPin. If the testPin is between 0 and 21, it works. No port above 21 works though.

Thanks for your help

int ledPin = 13; // select the pin for the LED int testPin = 21;

void setup() { // declare the ledPin as an OUTPUT: pinMode(ledPin, OUTPUT); pinMode(testPin, OUTPUT); }

void loop() { // turn the ledPin on digitalWrite(ledPin, HIGH); digitalWrite(testPin, HIGH);


// turn the ledPin off: digitalWrite(ledPin, LOW); digitalWrite(testPin, LOW); delay(250); }

Lefty, I'm an idiot. The problem is in my connector. I should have seen this, I'm sorry to waste your time.

Thanks again

Nothing wrong with your sketch, I changed it to pin 22 and loaded into my Seeeduino mega board and pin 22 toggles fine. Are you sure you have identified the pin numbers correctly on the shield connectors? You may be toggling the correct pins but measuring or wiring to the wrong pin numbers.

[edit]Edit: Just saw your reply, your not a idiot, just a beginner to arduinos. ;)[/edit]