It's been quite a while since I wrote my last Arduino sketch, probably around a year or more. So, I'm not sure if I remember wrong, if something changed with the functions, or if it's just me and my cheapo parts
Hopefully someone will help me get to the bottom of this one.
I had a project involving LEDs and shift registers that I did some time ago using an UNO. Then I modified it to run directly from a homemade board with an ATMEGA328 on it. It worked fine. So I decided to take it a step further and use a nano with a home made shield to neaten it up and shrink the board.
So I bought one of those cheap $2 chinese nano clones off Ebay. The ones that use the CH340 USB that's a pain to get going... but I got it going.
I pull up the sketch on an UNO, plug in my circuit, and it works just fine. I plug the nano into the protoboard, and look up a board pinout. According to what I see on the internet, D2 is board pin 5, D3 board pin 6, and so on. So I set up my sketch:
#define DIG2 5 #define DIG3 6 #define DIG4 7
and so on. And... the thing goes haywire. LEDs don't work, shifters don't work, nothing works.
Playing around with the pins and blink sketch, I found that D2 is #2, D3 is #3, D4 is #4, and so on. Real easy. Changed that in the sketch, and now the circuit is up and running.
So, can someone clear this one up for me? As I remember it, what you usually did was use the board pin number to address the output pins, or if you were using a standalone atmega, you addressed with the chip pin number.
I don't remember it being D2 is #2, D3 is #3, D4 is #4, etc. But of course, I haven't touched this stuff in a year or more so I could be perfectly wrong. If that's the case, for analog pins would I do the same thing... use 2 for A2, 3 for A3, and so on?