Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Multiple tone() outputs

  1. #1

    Multiple tone() outputs

    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

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,757
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •