
The Arduino way of counting the digital and analog pins just hides away complexity for the beginner. So internally we use a different counting system based on the pin function. But the internal code doesn't know, where the physical pins are located and the actual location can also depend on the packaging. TL DR: For building the circuit we must refer to pin positions (like where is Vcc, where is ground) to connect the chip/microcontroller correctly. For the code its just the third digital output hardware and so on. Where that pin is physically located on the board isn't interesting for the code, nore does the code know the actual location. So D2 means the third digital pin inside the Arduino framework. Those are the numbers, that are normally written only the Arduino board. So for the convenience of beginners (which are targeted by the Arduino framework) the digital and analog pins are just numbered. On an Arduino you have mainly digital and analog pins, which can be controlled.

So this counting only makes sense in the context of placing this specific package of the chip into a circuit (like where is Vcc, where ground and where do I need to connect to that specific digital pin), but makes no sense to use for the code inside the controller.įor referring to pins from inside the controller (aka in the code) we use the function of the pins. Each package has a different pin order and form factor. Also the microcontroller on the inside of its package doesn't know in which package it got stuck by the manufacturer. Those pins cannot be referenced by the code (wouldn't make much sense). This also includes special pins like Vcc, GND and Reset. The first way is only for referring to specific pin positions from the outside, for example when you are building the actual circuit. Referring to the pins by their function.



