A0 works as analog input, but why doesn't A5 seem to?


  • Jr. Member
  • **
    • Posts: 6
    • View Profile
I'm having trouble and not sure why: Have a circuit set up with a sensor attached to A0, and it reads fine; but if I attach the sensor to A5, it does not report the input.

Here is my code:


#include <SPI.h>

int readValue1 = 0;
int readValue2 = 0;

// setup for TinyZero
#if defined(ARDUINO_ARCH_SAMD)
  #define SerialInterface SerialUSB
  #define SerialInterface Serial

void setup() {


void loop() {

  String dataString = "";

  readValue1 = analogRead(A0);
  readValue2 = analogRead(A5);

  dataString += String(readValue1);
  dataString += ",";
  dataString += String(readValue2);





My circuit is:
 VCC ---> 220ohm ---> IR-emitter ---> GND
VCC ---> 10k ohm ---> A0 [or A5]
                                |--> IR-detector ---> GND

This works as expected when connected to A0: it reports low values when there is IR light striking the IR-detector, and reports high values when the light is blocked. That is, in serial monitor, we get sensor value in A0, and nothing meaningful in A5, as expected:
A0, A5
361,382 <-- when light blocked
349,373 <-- blocked
340,354 <-- blocked

But when connected to A5, it doesn't report sensor value in A5:
A0, A5
that is, here the second column should be low; but it never is.

I'm not sure what is wrong here?

Thank you!


  • Jr. Member
  • **
    • Posts: 6
    • View Profile
For what it's worth... I hooked up the sensor to A2 instead of A5 and it worked fine.
Not sure what is wrong (is A5 not an analog input?) but will go ahead and use A2.


  • Administrator
  • Hero Member
  • *****
    • Posts: 175
    • View Profile
Hello there,

A4 and A5 are also the pins used for I2C devices (A4-SDA, A5-SCL), which can normally be used as regular analog pins when no I2C devices are being interfaced, but the TinyZero has the option of an onboard accelerometer that relies on I2C. It is likely you have an accelerometer populated on your board that is interfering with your ability to use pin A5 for regular analog. You can check this with the pictures on the product page that show where the small black chip is: https://tinycircuits.com/collections/processors/products/tinyzero-processor?variant=21137366515796

If you click between the Not Present and Present options, it should be clear where the part is.

Let me know if that seems to be the case!



SMF spam blocked by CleanTalk