I would like to use as much as possible GPIO pins on Arduino Mega especially with (mis)using pinMode(x,INPUT); and pinMode(x,INPUT_PULLUP); to achieve two things at the same time - drive something else by the pin weakly down or up and measure the logical level there with digitalRead(x) to detemine, if that "something else" is input, or outputting some logical level.

Also I need I2C, Serial over USB and nothing else.

On Arduino UNO/nano/micro/pro it works just fine for Digital pins (except D0/D1 (RX/TX), D13 (LED as strong pull-down), A4/A5 (I2C) and A6/A7 which are not digital IO). The problem is limited number of pins, so I bought ArduinoMega.

The question is - which pins can be used that way there? So far I am aware of D0/D1 (RX/TX), D20/D21 (I2C) and D13 (LED). The rest (D2-D12, D14-D19, D22-D52 and A0-A15) seem aviable and usable. Or I am missing something else?

Are there some libraries/objects I should disable to not interfere with my script?

Thank you.

  • "D13 (LED as strong pull-down)," You are misinformed there. D13 is also connected to the input of a comparator (LM358) which then drives the LED. The LED does not present a strong pulldown. If you are not using I2C or SPI, those pins are also available.
    – CrossRoads
    Commented Apr 26, 2018 at 0:51
  • I looked at it, but it depends on version, store.arduino.cc/arduino-uno-smd-rev3 shows still connection of direct led+resistor on D13, store.arduino.cc/arduino-uno-rev3 have comparator, my old UNO (with DIP) also have resistor+LED, Nano also have LED+resistor and no comparator. So only some revisions of some types have the comparator at all.
    – gilhad
    Commented Apr 26, 2018 at 2:07
  • My last project had problems just for this reason and I was forced to rearrange the pin usage to avoid D13 for this very reason (unconnected D13 with INPUT_PULLUP had show like 1.3V on voltmeter, while all others show over 4.5V ), so it is not just matter of some PDF, but real physical units proves that too.
    – gilhad
    Commented Apr 26, 2018 at 2:08

1 Answer 1


All those pins should be available. But if you want to use Pin change interrupts, you have to check which pins are usable.

  • No more than 2 pin interrupts and it is not so much needed anyway (just reading buttons, digitalRead can work just as well, as there is a lot of points, where I can check regulary)
    – gilhad
    Commented Apr 25, 2018 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.