digital pin 20 and 21 won't work as digital inputs on Mega R3

Hello everyone,

My question is, digital pin 20 and 21 don't work as digital inputs on Mega R3. Is it possible to use 20 and 21 pin as digital inputs? The other pins both analog and digital are working properly. I have been making a MIDI controller with it and wrote Firmata - StanderdFilmata on it.

Mac os 10.8.5 Arduino 1.0.6 with Mega R3

Kind regards,

What leads you to believe those two pins do not work?

[quote author=Coding Badly link=msg=2194913 date=1429487563] What leads you to believe those two pins do not work?

[/quote]

Thanks for the reply but I have no idea why those don't work...

What we want to know is "How did you determine that your pins weren't working for input?". Usually when someone says that certain pins "don't work" it is because they are using them wrong so we have to assume that you are using them wrong. The only way to fix that is to tell you how to fix your mistakes. To do that we have to find out which mistakes you made.

Those pins are normally for I2C and have 10K pullup resistors to 5V according to the schematic. If configured as input and you have nothing connected, you should read HIGH.

dlloyd:
Those pins are normally for I2C and have 10K pullup resistors to 5V according to the schematic. If configured as input and you have nothing connected, you should read HIGH.

Hello johnwasser and dlloyd.
Thanks for replying.
Sorry Im a very beginner for Arduino and have small knowledge of electronics.
What I have done is, all digital pins (except 0 and 1) are connected with on/off push switches and 10K resistors. And 2-19 and 22-53 inputs are working properly, since I can see on/off signals through a maxuino software.
Only 20 and 21 don’t work. I mean there are no signals in.
What should I do now? Thank you very much for your helping!

I wrote Firmata - StanderdFilmata (plz see the attachment) on Arduino.

StandardFirmata.ino (20.7 KB)

Only 20 and 21 don't work. I mean there are no signals in.

If your resistors are connected as pulldown (from the input to GND), then you will not be able to read a change in input signal for pins 20 and 21 when you press the associated pushbutton.

For these pins only, you don't need external resistors, just connect the pushbutton from the input to GND. You should read HIGH when the switch is open and LOW when the switch is closed. If this is opposite to the operation of the other switches, you can invert these signals in your code.

If you prefer to have them all work the same in hardware, then you'll need to use a lower value resistor (i.e. 330 ohm - 1K) connected pulldown (input to GND). This will essentially override the 10K pullups installed on the PCB for pins 20 and 21.

dlloyd: If your resistors are connected as pulldown (from the input to GND), then you will not be able to read a change in input signal for pins 20 and 21 when you press the associated pushbutton.

For these pins only, you don't need external resistors, just connect the pushbutton from the input to GND. You should read HIGH when the switch is open and LOW when the switch is closed. If this is opposite to the operation of the other switches, you can invert these signals in your code.

If you prefer to have them all work the same in hardware, then you'll need to use a lower value resistor (i.e. 330 ohm - 1K) connected pulldown (input to GND). This will essentially override the 10K pullups installed on the PCB for pins 20 and 21.

To use 1K resistors and it works! Thank you very much!

Thanks to the Forums I have learned far more than I thought possible. Perfect example is this thread, as I experienced the very same problem. After re-reading all the Arduino web page information on the Mega 2560 and triple checking not only my sketch but my hardware as well, I was un-able to get the expected results, ie: digital reading pins 20-53 and expecting either HIGH or LOW. Pins 20 and 21 showed absolutly no indication of the same activity as was applied to pins 22-53. So I made a hardware change as indicated in this thread and VOILA!!! Next time I'll check here first. So to all who ask and answer, Thank You.