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() {
    adc->setAveraging(16); // set number of averages
    adc->setResolution(16); // set bits of resolution
    for (int i = 0; i < 14; i++) pinMode(RECIEVERS[i], INPUT);

void loop() {
    for (int i = 0; i < 14; i++) {
        Serial.print(" | ");

Is there a problem with my code or is my Teensy damaged?

1 Answer 1


The Kinesis 66 (the chip on the Teensy 3.6) has two ADC modules. Each one talks to different pins.

By default the configuration functions in that library configure ADC0, so unless you tell it otherwise, you will only be configuring half the ADC pins.

You should call each of the configuration functions twice, once for ADC0 and once for ADC1:

adc->setAveraging(16, 0); // set number of averages
adc->setResolution(16, 0); // set bits of resolution
adc->setConversionSpeed(ADC_CONVERSION_SPEED::HIGH_SPEED_16BITS, 0);
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::VERY_HIGH_SPEED, 0);

adc->setAveraging(16, 1); // set number of averages
adc->setResolution(16, 1); // set bits of resolution
adc->setConversionSpeed(ADC_CONVERSION_SPEED::HIGH_SPEED_16BITS, 1);
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::VERY_HIGH_SPEED, 1);
  • Exactly it. Thanks so much.
    – Ietpt123
    Oct 24, 2019 at 21:18
  • In the new version of the Library that must be adc->adc0->xy and adc->adc1->xy
    – heimi
    Apr 13, 2022 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.