1

I am attempting to play a wav file from an SD card using a Teensy 3.5. I am using this buzzer and I have the following code currently:

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioPlaySdWav           playSdWav1;     //xy=557,157
AudioOutputPWM           pwm1;           //xy=889,184
AudioConnection          patchCord1(playSdWav1, 0, pwm1, 0);
AudioConnection          patchCord2(playSdWav1, 1, pwm1, 0);
// GUItool: end automatically generated code

void setup() {
  // put your setup code here, to run once:
  Serial.begin(4800);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Play");
  playSdWav1.play("sound.wav");
  delay(100);
  while (playSdWav1.isPlaying()) {
    delay (100);
  }
}

I don't know which pin is supposed to be outputting the PWM signal. I tried searching "patchCord1" to see what the parameters for it are, but was unsuccessful. The code was generated by The Audio System Design Tool.

As for the hardware configuration, I am attempting to wire the I/O pin to various PWM pins (to check for output) with no success. I have GND to Analog Ground and VCC to 3.3V (250 mA max). This is according to this diagram.

Which PIN is the Teensy supposed to output the pulses to?

Edit:

I can get the buzzer to work by using manual PWM (analogWrite), so I know that it functions.

1
  • I will edit the question to add a little bit of specifics. But, my question is first, which pin is supposed to be connected to I/O. And second, am I doing this right at all?
    – STF_ZBR
    Commented Sep 19, 2020 at 22:44

1 Answer 1

1

The documentation implies you have to combine pins 3 and 4.

Here is a circuit diagram:

https://www.pjrc.com/teensy/gui/img/pwmdualcircuit.jpg

enter image description here

Source:

https://www.pjrc.com/teensy/gui/?info=AudioOutputPWM

1
  • After wiring it this way, I still receive no sound. But, I am noticing that the serial monitor is constantly entering "Play." But, it seems it shouldn't do that until the sound has completed? The sound is 5 seconds and it's doing about 10 per second.
    – STF_ZBR
    Commented Sep 22, 2020 at 1:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.