josephcesario
New member
Hi everyone -- I'm sure this is a very novice question but I'm having some problems playing a sound through external speakers, using Teensy 3.2 plus audio shield. I just want one of two songs to play when a button is pressed. (Code is pasted below.) Everything works perfectly fine when I play through the headphone jack of the audio shield, so I'm pretty sure the problem isn't the code. The problem is when I try to get it to play through the external speaker.
Circuit looks like this:
The speaker outputs just a loud fuzz noise. You can barely make out the song being played when the button is pressed, but the loud noise is just constant.
I've tried with a 4ohm 20w speaker and a 8ohm 3w speaker. Same problem with both. Also tried with 100k instead of 4.7k resistors going into the op amp. Didn't change the problem at all.
I've searched the forum (e.g.,
) and other online help. One problem I'm having is that the other examples I'm seeing are using the LM386 whereas I have the TLV2462 (
and
), and I suspect that me not fully understanding this op amp is one major source of the problem.
Any help would be greatly appreciated, thank you!!
Circuit looks like this:
The speaker outputs just a loud fuzz noise. You can barely make out the song being played when the button is pressed, but the loud noise is just constant.
I've tried with a 4ohm 20w speaker and a 8ohm 3w speaker. Same problem with both. Also tried with 100k instead of 4.7k resistors going into the op amp. Didn't change the problem at all.
I've searched the forum (e.g.,
HTML:
https://forum.pjrc.com/threads/55720-Using-LM386-audio-amp-with-audio-shield-line-out
HTML:
https://cdn-shop.adafruit.com/datasheets/tlv2462.pdf
HTML:
https://www.adafruit.com/product/808#technical-details
Any help would be greatly appreciated, thank you!!
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Bounce.h>
// WAV files converted to code by wav2sketch
#include "AudioSampleCucaracha.h"
#include "AudioSampleTarantellalow.h"
// Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
AudioPlayMemory sound0;
AudioPlayMemory sound1; // six memory players, so we can play
AudioMixer4 mix1; // two 4-channel mixers are needed in
AudioOutputI2S headphones;
AudioOutputAnalog dac; // play to both I2S audio board and on-chip DAC
// Create Audio connections between the components
//
AudioConnection c1(sound0, 0, mix1, 0);
AudioConnection c2(sound1, 0, mix1, 1);
AudioConnection c8(mix1, 0, headphones, 0);
AudioConnection c9(mix1, 0, headphones, 1);
AudioConnection c10(mix1, 0, dac, 0);
// Create an object to control the audio shield.
//
AudioControlSGTL5000 audioShield;
// Bounce objects to read six pushbuttons (pins 0-5)
//
Bounce button0 = Bounce(0, 5);
Bounce button1 = Bounce(1, 5); // 5 ms debounce time
void setup() {
// Configure the pushbutton pins for pullups.
// Each button should connect from the pin to GND.
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(10);
// turn on the output
audioShield.enable();
audioShield.volume(0.5);
// by default the Teensy 3.1 DAC uses 3.3Vp-p output
// if your 3.3V power has noise, switching to the
// internal 1.2V reference can give you a clean signal
//dac.analogReference(INTERNAL);
// reduce the gain on mixer channels, so more than 1
// sound can play simultaneously without clipping
mix1.gain(0, 0.4);
mix1.gain(1, 0.4);
}
void loop() {
// Update all the button objects
button0.update();
button1.update();
// When the buttons are pressed, just start a sound playing.
// The audio library will play each sound through the mixers
// so any combination can play simultaneously.
//
if (button0.fallingEdge()) {
sound0.play(AudioSampleCucaracha);
}
if (button1.fallingEdge()) {
sound1.play(AudioSampleTarantellalow);
}
}