Hi everyone,
I am making an interactive wearable project and I decided to use the Teensy 3.2 because of how compact it is. It's my first time using the Teensy. I needed to add sound to my project so I connected the audio adaptor board to be able to output sounds stored on an SD card through a 0.5W 8ohm speaker. In a previous project using Arduino I used an LM386 to amplify the sound going into a speaker following this circuit I found in a tutorial (see attached circuit diagram) so I thought I could do the same with the Teensy.
With the audio board, I connected the Left line out to a 1K resistor connected to pin 3 of the LM386 and the Ground pin next to the left line out to pin 2 of the chip. All the capacitors shown in the diagram are connected the same as well. However when I tried the WavFilePlayer Sketch Example, I got good sound from the headphones but only a constant clicking sound comes out of the speaker with some noise. Is it possible that no sound is coming out of the speaker because the minimum supply voltage required for the LM386 is 4V and the Teensy only supplies 3.3V? Or could the problem be with the speaker? Here is the code from the WavFilePlayer example:
Any advice would be appreciated. Thank you!!
I am making an interactive wearable project and I decided to use the Teensy 3.2 because of how compact it is. It's my first time using the Teensy. I needed to add sound to my project so I connected the audio adaptor board to be able to output sounds stored on an SD card through a 0.5W 8ohm speaker. In a previous project using Arduino I used an LM386 to amplify the sound going into a speaker following this circuit I found in a tutorial (see attached circuit diagram) so I thought I could do the same with the Teensy.
With the audio board, I connected the Left line out to a 1K resistor connected to pin 3 of the LM386 and the Ground pin next to the left line out to pin 2 of the chip. All the capacitors shown in the diagram are connected the same as well. However when I tried the WavFilePlayer Sketch Example, I got good sound from the headphones but only a constant clicking sound comes out of the speaker with some noise. Is it possible that no sound is coming out of the speaker because the minimum supply voltage required for the LM386 is 4V and the Teensy only supplies 3.3V? Or could the problem be with the speaker? Here is the code from the WavFilePlayer example:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySdWav playWav1;
AudioOutputI2S audioOutput;
AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
AudioControlSGTL5000 sgtl5000_1;
// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14
void setup() {
Serial.begin(9600);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(8);
// Comment these out if not using the audio adaptor board.
// This may wait forever if the SDA & SCL pins lack
// pullup resistors
sgtl5000_1.enable();
sgtl5000_1.volume(0.3);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
// stop here, but print a message repetitively
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
}
void playFile(const char *filename)
{
Serial.print("Playing file: ");
Serial.println(filename);
// Start playing the file. This sketch continues to
// run while the file plays.
playWav1.play(filename);
// A brief delay for the library read WAV info
delay(5);
// Simply wait for the file to finish playing.
while (playWav1.isPlaying()) {
}
}
void loop() {
playFile("SDTEST1.WAV"); // filenames are always uppercase 8.3 format
delay(500);
playFile("SDTEST2.WAV");
delay(500);
}
Any advice would be appreciated. Thank you!!