Newbie to Arduino Programming

Hello,
I am very new to Arduino programming. When programming how do I reference the PINs in a Arduino Mega?
For example, for PIN A0. Do i code with 0 or A0?

Also, when using MCP23017 Module, do i use PIN 0 or GPA0?

Best Regards
Bob

so as they are marked on mega board.

You can always use the pin names as printed on the board as the A* pin names will be converted to the corresponding actual pin numbers when the code is compiled.

When used with the analogRead() function you can refer to the A* pins by just their number because the compiler understand the difference between say digital in 0 and analogue pin 0 but I suggest that you stick to the full names

Out of interest try printing the value of A0 to see the real pin number, which is not 0

14?

So for Analog, use A0, A1 etc?
And for digital, D0, D1, etc?

No on a Mega

Does a Mega have pins labelled D0, D1 etc ?

arduino mega pinout diagram - Google Search

Arduino Mega Pinout Diagram - (duino4projects.com)

ardunio_mega_pinout.jpg (961×680) (duino4projects.com)

I see D next to digital pins in this diagram i have from Arduino. That is why i askedd about digital pinsd as well.

My question was

Here is a picture of a genuine Mega board
image
Does it have pins labelled D0, D1 etc ?

No it does not. Point taken.
Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.