Using Pins 18 & 19 while using the audio library (without the audio board)?

Status
Not open for further replies.
Hi all. I'm sure this is a silly question, but I've been googling for a few days with no luck.

TL;DR: Is it possible to use pins 18 and 19 (on a Teensy 3.2 without the audio board) as normal digital OUTPUTs (like to light LEDs) if I've got the audio library in use? I know the audio board uses pins 18 and 19, and I'm assuming based on what I'm seeing that those pins won't work if the audio library's in use (even without the board). But I'd like confirmation.

This is the line that causes those pins to stop working:
Code:
sgtl5000_1.enable();

Here's sample code:https://pastebin.com/raw/J5XYkpsD

Pins 18 and 19 work if the audio isn't enabled. They stop working as soon as it's enabled. My hunch is that the cause is super obvious to more experienced folks, but that's definitely not me at this point :)

Background: The basic idea is a tuner turning LEDs on when pitches are hit (so 12 LEDs, one for each note). The project works great, but I've got the TeensyView, which limits my pin options. (I know I could use the pins on the bottom, but I'd rather avoid that if I can.) 12 notes, 12 pins. TeensyView takes up the rest, so I need 18 and 19, if I can get 'em :)

Thanks!
 
It depends which parts of the audio library you're using. There are dozens of different features in the audio lib. It all depends on which ones you've actually used. Only a few of them (the control objects) actually use I2C on pins 18 & 19.

If you're using the audio shield, then you must use AudioControlSGTL5000, which does use those 2 pins. The audio shield won't turn on without communication from those 2 pins.

If you use only the DAC output, PT8211, or other features that don't require those pins, then they can be used as ordinary pins.
 
It depends which parts of the audio library you're using. There are dozens of different features in the audio lib. It all depends on which ones you've actually used. Only a few of them (the control objects) actually use I2C on pins 18 & 19.

Thanks so much, Paul. My code (that used the AudioControlSGTL5000) started on a Teensy 3.6 with the audio board, and though I tweaked it a bit when I moved to the 3.2 without the audio board, I hadn't thought to revisit the audio code and strip what was unnecessary. Your comment made me re-approach and realize I had some stuff in there I wasn't actually using. Works perfectly now!

In case anybody stumbles on this in the future, here's code that works for pitch detection with a microphone on pin 16, without the audio board.
 
Note on boards like the audio board or the prop shield that expect to use pin 18/19 as the standard i2c pins, there are pull-up resistors on pins 18/19 to 3.3v. These pull-up resistors might interfere with using the pin in some fashion.

If you are going to use pins 18/19 for i2c, then you need to verify that you use different i2c addresses than the devices on the extra boards.
 
Status
Not open for further replies.
Back
Top