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.

Tech Explorations Arduino intermediate level

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 Wi-Fi, 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.


Last Updated 10 months ago.

We publish fresh content each week. Read how-to's on Arduino, ESP32, KiCad, Node-RED, drones and more. Listen to interviews. Learn about new tech with our comprehensive reviews. Get discount offers for our courses and books. Interact with our community. One email per week, no spam; unsubscribe at any time

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}