Why would this not work with a 1280 MEGA?

The rotary encoder code found on this site: How to use USB Host Shield Hardware Manual Guide (Complete And Easy) - Circuits At Home works fine with my Duemilinove. However, once I take the same code, wired the exact same on a Mega, and using the same encoder, it refuses to see anything.

The serial begins, but I see nothing from the encoder. I know the Mega works fine and I've tried two different pin variations. what could this be?

I think the problem might be that on an Arduino Mega the analog input pins are numbered as digital pins above 53, not above 13.

Try using the names A0 and A1 instead of 14 and 15. That should select the right pins.

Your problem is that the sketch uses a direct port access command, and direct port addressing is not portable between the 328 and 1280 chips:

old_AB |= ( ENC_PORT & 0x03 ); //add current state

The atmega 328 and 1280 use different port/pin mapping. You will have to use

Try changing:

#define ENC_PORT PINC // pins 14 and 15 = PORTC bit 0 and bit 1 on atmega328

To:

#define ENC_PORT PINJ // pins 14 and 15 = PORTJ bit 1 and bit 0 on atmega1280

pin mapping info: https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0

Lefty

It wasn't PINJ, but I found that PINA with pins 22 and 23 worked a charm. Thanks!

Pin 14, Pin 15, and PORTJ woud be close but reversed (14=J1, 15=J0) and would require moving wires from A0/A1 to D14/D15

Pin A0, Pin A1, and PORTF would work with the existing wiring.