I have been playing with microcontrollers for a few weeks. I have an Uno, a Mega 2560 and a Nano but I'm asking specifically about the Mega.
Being a newbie (still) I thought you can/could use any pin????
I tried to use pin 1 for an IR Receiver brick but it didn't seem to work? Then I tried pin 0, same thing.
Finally I tried pin 22 and all was sweet. Worked perfectly.
Then I wanted to move the sketch (and mounted breadboard) to the Nano which, of course, doesn't have a pin 22. So I used pin 21 (A7 on the Nano) and that didn't seem to work either. So I used pin 13 and all is okay again.
I read the specifications and I know that pins 0, 1 and 14 - 21 are special communications pins but is that ALL they can do? Can they be used as ordinary digital pins? To switch on and off LEDs, for instance?
I also noticed that pins 50 to 53 have special functions(SPI?)! So can't I use these to switch LEDs either?
I'm surprised to notice there are NO "pinMode" set in my whole Mega sketch (over 600 lines of code and comments)!!!!
My Mega is currently driving a 7 Segment (manually no library), an 8X8 LED module (with MAX7219) and the IR Receiver (manually but I do use IRremote.h to "start" the IR brick etc but no library calls). The 8X8 uses the LedControl.h completely. :)
And there are NO pinModes at all. Could this be why the IR Receiver didn't work on the communication pins?
I could/will just try it but I am hoping for a more informative answer from you smart people :D
Why it worked on pin 22 and pin 13 with no pinModes but won't on pins 0, 1, 21?