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

Thread: Adding a buzzer to Teensy 2.0 controller

  1. #1
    Junior Member
    Join Date
    May 2022

    Adding a buzzer to Teensy 2.0 controller

    Hello. I am making a USB controller using a Teensy 2.0 and I wanted to add a buzzer to it. When you're hit, fall, or die I want the buzzer to rumble for a second and then stop. I have no idea how to do this, so any help would be appreciated.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    This is probably best to approach as 3 smaller projects.

    #1 - Get the software to send something when the event happens which you want to cause buzz. Maybe try to have it change the LEDs on your USB keyboard. This is a first critical step, because the rest won't be possible until your PC sends some sort of message Teensy can receive.

    #2 - If you got a keyboard LED to change, the next step is programming a Teensy to act as a USB keyboard. Use Tools > USB Type to select it. Then try to write code on the Teensy side which monitors the received LED info.

    #3 - The last part is actually wiring a buzzer up to Teensy and adding code to turn it on/off. We can help more if you choose a buzzer and share a link to the technical info. Details matter for this sort of circuitry help.

  3. #3
    Not sure what buzzer you are referring to but these are what I've used.

    Just send a pwm to them of a frequency of your choice. code to drive a buzzer on then off at 500 hz

      analogWriteFrequency(BUZZ_PIN, 500);
        analogWrite(BUZZ_PIN, 127);
        analogWrite(BUZZ_PIN, 0);

Posting Permissions

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