Arduino programming guide series
"0" or "A0" when used with analogRead()?
The short answer is, it does not matter.
But there's a catch.

When you use the analogRead() function, "0" and "A0" refer to the same pin, the analog pin 0.
These two invocations of analogRead() are equivalent:
analogRead(0);
analogRead(A0);
Therefore, when you use analogRead() or analogWrite(), it doesn't matter which pin name or number you use.
However, there's a "catch".
It is possible to use an Arduino analog pin as if it was a digital pin.
For example, you can write:
digitalRead(A0);
This will return either HIGH or LOW, instead of a number from 0 to 1023 (assuming you are using an Arduino Uno).
Points to remember:
- If you use an analog pin 0 with digitalWrite() or digitalRead(), then you must use the full analog pin designator ("A0", "A1", etc).
- If you use an analog pin with analogRead() or analogWrite(), you can simply use the number of the analog pin ("0", "1", etc.) or the full analog pin name ("A0", "A1", etc.).
New to the Arduino?
Arduino Step by Step Getting Started is our most popular course for beginners.
This course is packed with high-quality video, mini-projects, and everything you need to learn Arduino from the ground up. We'll help you get started and at every step with top-notch instruction and our super-helpful course discussion space.
Jump to another article
3. Focus on the type parameter in "println()"
4. "0" or "A0" when used with analogRead()?
5. What is the "_t" in "uint8_t"?
6. Save SRAM with the F() macro
7. What is the gibberish in the Telnet output?
9. Confusing keywords? follow the source code trail
10. The interrupt service routine and volatile variables
11. The problem with delay() and how to fix it
12. How to deal with the millis rollover
13. Can you use delay() inside Interrupt Service Routine?
15. A closer look at line feeds and carriage returns
16. Understanding references and pointers
17. Simple multitasking on the Arduino
19. Concurrency with the Scheduler library on the Arduino Due and Zero
20. Bitshift and bitwise OR operators
21. What is a "static" variable and how to use it
22. Understanding the volatile modifier

Done with the basics? Looking for more advanced topics?
Arduino Step by Step Getting Serious is our comprehensive Arduino course for people ready to go to the next level.
Learn about Wifi, BLE and radio, motors (servo, DC and stepper motors with various controllers), LCD, OLED and TFT screens with buttons and touch interfaces, control large loads like relays and lights, and much much MUCH more.