Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: Analog inputs on teensy 3.1 smt pads, A15-A20

  1. #1
    Senior Member
    Join Date
    Dec 2013
    Posts
    125

    Analog inputs on teensy 3.1 smt pads, A15-A20

    Hi,

    I'm probably missing something obvious, but I can't get the pads on the underside of the teensy 3.1 to act as analog inputs. All the others work fine, and my circuit /soldering is solid. Do I have to enable these inputs separately? Just using analogRead example and changing the pin numbers at the mo.

    Thanks,

    Matt

  2. #2
    Senior Member
    Join Date
    Dec 2013
    Posts
    125
    Figured it out from looking at analog.c. It seems that for analog inputs 0-13 I can just use analogRead(0-13). However from 15-20, I have to either use analogRead(A15), or the numbers for the digital pins, analogRead(26).

    Tad confusing!

  3. #3
    nothing confusing here, the "Welcome to Teensy 3.1" postcard, that you've surely got along with your board, does list all these numbers

  4. #4
    Senior Member
    Join Date
    Dec 2013
    Posts
    125
    Quote Originally Posted by PaulD View Post
    nothing confusing here, the "Welcome to Teensy 3.1" postcard, that you've surely got along with your board, does list all these numbers
    Yeah I know what you mean but I wasn't aware you can use 'A15'.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    13,324
    Early in Arduino's history, they unfortunately decided to number the analog and digital pins with two separate 0-based numerical ranges. The digital pins were 0 to 13 and the analog pins 0 to 5.

    But what happens if a pin has both analog and digital capability?

    A few years ago, analogRead() was on changed for Arduino Uno, so you could use analogRead(0) or analogRead(14). The name "A0" was defined to be 14. Before this change, only analogRead(0) could be used. I believe the idea was to transition to calling the analog pins A0, A1, A2 in examples and documentation. But hundreds of websites, tutorials and examples have the 0-based numbers.

    The problem with the scheme, aside from the confusion of 3 different ways to refer to an analog pin, is things get very messy if a board has more than 14 analog pins. One of the 3 ways, the oldest 0-based analog numbering scheme, suddenly doesn't work, because analogRead(14) means to read from the A0 pin.

    Teensy aims for as much Arduino compatibility as possible. With Teensy 3.0, exactly 14 analog pins were present, which worked out very nicely. But Teensy 3.1 has more, which is nice in that you can connect more analog signals without an external mux. But unfortunately going over 14 breaks one of the 3 ways of referring to analog pins: the oldest way that's very widely used in lot of examples.

  6. #6
    true story, but didnt the confusion start in the frist place with the mulitplexer numbers being different than the pin numbers on avr? I always thought that that was the motivation of the Ax names, correct me when I'm wrong.. just interested

  7. #7
    Senior Member
    Join Date
    Dec 2013
    Posts
    125
    Quote Originally Posted by PaulStoffregen View Post
    A few years ago, analogRead() was on changed for Arduino Uno, so you could use analogRead(0) or analogRead(14).
    Well that explains it!

  8. #8
    It is confusing. analog 14 and up are labeled in the same manner on the card as analog 13 and lower: "A14". I couldn't tell from this that 0-13 could be referenced by analogRead(13), but for 14 and higher I had to put in analogRead(A14).

    Thanks, mattomatto!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •