trouble reading Analog pins A14 and above

Status
Not open for further replies.
hello !
i'm totally new to Teensy3.5, switched from Arduino one week ago, looking for more speed and memory, for a sequencer projet.
right now i'm learning the basics and i have trouble reading some analog pins…

i have potentiometers connected to analog pins from A0 until A19

this simple sketch gives correct values when reading Analog pins A0 to A8, but not for A14 until A19.

Code:
    for ( byte i = 4; i < 18 ; i++ )
    {
        Serial.print(analogRead(i)) ;
        Serial.print("\t") ;
    }
    Serial.println();

any idea what i'm doing wrong ?

Sylvain
 
Hello and welcome here,

I think you mistook analog pins for digital pins.
Digital 1 is not analog A1, look at reference here https://www.pjrc.com/teensy/pinout.html .

Try this:
Code:
uint8_t adc_pins[] = {A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19};

for ( byte i = 4; i < 19 ; i++ )
    {
        Serial.print(analogRead(adc_pins[i])) ;
        Serial.print("\t") ;
    }
    Serial.println();

Also in your code you never reach index 18 (19th input).

best regards
 
the Teensy analogRead maps 0..13 -> A0..A13. It does not map numbers above 13 into the appropriate analog register, since A0 is actually 14.


ok, that's the answer to my previous post :) i was implying too much about A14 and above.. good to know though, i didnt read it until today :)


thanks Michael and Larry for those fast answers,


Sylvain
 
Status
Not open for further replies.
Back
Top