I have a project with 30 buttons connected, all using input_pullup. My last button (connected to pin 51) always shows low...even with a physical pullup resistor connected.
I wasn't sure if maybe pins 51/52 didn't have internal pullups or what's going on. The button is fine and works on other inputs as expected. I wrote a demo sketch to try to figure out what's going on. Essentially, I set pins 50, 51, 52, and 12 all to input_pullup and read them with both buttons connected and no buttons connected and this is what I get.
Pin50: 1
Pin51: 0
Pin52: 0
Pin12: 1
Always. If I upload the sketch to a mega with no buttons connected, I get 1s on all 4 inputs. What am I missing?
Yes. In fact, I just figured out that the ethernet library seems to write to the pins in the 50s which seems insane considering they shouldn't be there on most arduinos. I'll post a follow up.
Pins 50-52 on the Mega are the SPI bus. The SPI bus is used for communication with the Ethernet shield. Because the SPI bus is on different pins from one board to another, the connections to the Ethernet shield are made via the ICSP header, which is at the same place on all the boards. The ICSP header has connections to those same pins 50-52 on your Mega. When you are using the SPI bus, you must only use pins 50-52 for SPI. You also are limited in how you can use pin 53.