Free US Shipping on orders over $150 with discount code "FREESHIP" at checkout

Playing sound with an Adafruit Trinket "mini Arduino"

November 15, 2013 2 Comments

We've itching to get the chance to play with the Adafruit Trinket, which is a tiny microcontroller that is only 3 cm by 1.5 cm (1 inch by 0.5 inch).  We were playing around with our little Piezo speakers and thought it would be fun to drive one with a Trinket.

It turns out that this is very easy to do!

0) We soldered the header pins to the Trinket

1) We found a sketch on Pastebin with the Star Wars Imperial March song.  Somebody took the time to record all the frequencies needed to play that song, and we are grateful to them.

2) We downloaded Adafruit's Arduino IDE version 1.05.   There are ways to patch your existing Arduino install, but it is much more difficult.  

3) We modified the code from Pastebin to use Pins 1 and 2 from the Trinket.  Pin 1 maps to the built-in LED and Pin 2 is how we drove the speaker

4) We scrounged up a mini-USB cord and tried to upload the sketch.  It turns out that the Trinket doesn't like USB 3.0 in some cases, so after a few tries we ran it through a USB 2.0 hub.  Be sure to tap the bootloader button on the Trinket prior to trying to upload the sketch.

It was that easy!  Here is a video of the result.

 




2 Responses

Craig
Craig

May 01, 2014

It sounds like you might have a hardware issue. We actually found that using a different pin on the Trinket helped. This might be because the LED on the Trinket is linked to Pin 1.

Jeff
Jeff

April 10, 2014

I am trying this out on my little Trinket and the sound coming out of it sounds sluggish and slow. Is there something in the code that I would need to tinker with to get it to sound more like yours?

Leave a comment

Comments will be approved before showing up.


Also in News

Ways To Use Raspberry Pi in the Classroom
Ways To Use Raspberry Pi in the Classroom

September 21, 2020

Raspberry Pi computers are useful for teaching students about computers and electronics. Discover ways to use Raspberry Pi in the classroom here.

Continue Reading

How a Micro:Bit Works: Getting Started
How a Micro:Bit Works: Getting Started

September 02, 2020

A Micro:Bit is a small computer board that you can code and connect to other parts to create electronics. Here are the basics of how a Micro:Bit works.

Continue Reading

How To Build a Robot Using Raspberry Pi
How To Build a Robot Using Raspberry Pi

August 28, 2020

Many people would like to make robots but don’t know where to start. In this guide, we go over how to build a robot using a Raspberry Pi so you can get started.

Continue Reading