I have a basic circuit, where I'm reading analog values from 14 infrared receivers.
I set the bit resolution to 16 but specific ports are returning 10 bit values (from 0 - 1024) instead of 16 bit values (from 0 - 65536).
I can confirm this is not a problem with my circuitry because when I've tested reading each individual sensor with a port that "works" and the correct range is returned every time.
Here is my code:
#include <ADC.h>
ADC *adc = new ADC();
const int* RECIEVERS = (int[14])
{
A15, A16, A17, A19, A20, A21, A22, A1, A2, A3, A6, A7, A8, A9
};
void setup() {
Serial.begin(4608000);
adc->setAveraging(16); // set number of averages
adc->setResolution(16); // set bits of resolution
adc->setConversionSpeed(ADC_CONVERSION_SPEED::HIGH_SPEED_16BITS);
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::VERY_HIGH_SPEED);
for (int i = 0; i < 14; i++) pinMode(RECIEVERS[i], INPUT);
}
void loop() {
for (int i = 0; i < 14; i++) {
Serial.print(adc->analogRead(RECIEVERS[i]));
Serial.print(" | ");
delay(1);
}
Serial.println("");
}
Is there a problem with my code or is my Teensy damaged?