Analog inputs on teensy 3.1 smt pads, A15-A20

Status
Not open for further replies.

mattomatto

Well-known member
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
 
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!
 
nothing confusing here, the "Welcome to Teensy 3.1" postcard, that you've surely got along with your board, does list all these numbers
 
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.
 
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
 
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!
 
Status
Not open for further replies.
Back
Top