Hi,
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
#else
#define SerialInterface Serial
#endif
void setup() {
SerialInterface.begin(9600);
delay(3000);
}
void loop() {
String dataString = "";
readValue1 = analogRead(A0);
readValue2 = analogRead(A5);
dataString += String(readValue1);
dataString += ",";
dataString += String(readValue2);
SerialInterface.println(dataString);
delay(1000);
}
----------------------
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
42,332
43,370
43,367
43,357
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
361,382
349,373
340,354
321,372
305,368
that is, here the second column should be low; but it never is.
I'm not sure what is wrong here?
Thank you!