Multiple tone() outputs

Status
Not open for further replies.
Hello,

I'd like to use multiple pins to connect multiple speakers to play different tones on each. Using the tone lib.

How many speakers can I plug to a teensy 3.6 that way? And on which pins? I tried to read the following https://www.pjrc.com/teensy/td_pulse.html, but it is not clear to me.

I'd need at least 6 tone() capable pins, or any other solutions not involving the tone library.

Regards,

Xavier
 
The tone() function only supports output to a single pin at a time.

You can get more with analogWriteFrequency() and analogWrite(). All the pins on the same timer get the same frequency, but the good news is Teensy 3.6 has 5 timers for PWM, so you can use this together with tone() to get the 6 signals you want. Details here: (scroll down to "PWM Frequency")

https://www.pjrc.com/teensy/td_pulse.html

However, the Teensy Audio Library might be a better choice? You can create dozens of oscillators and mixers to combine them all to a single signal, and then output that combined signal on either of the DAC pins. Then you'd only need a single amplifier and speaker. With the audio lib, you're not limited to merely square waves. So much more is so easy when you have a fast board like Teensy 3.6 which can digitally synthesize audio signals!

This tutorial page is the best place to get started with the audio library. Oscillators are covered in part 2-8 starting on page 20.

https://www.pjrc.com/store/audio_tutorial_kit.html
 
Status
Not open for further replies.
Back
Top