ArduboyTones - a library for generating tone sequences

Already done (as long as you’re comfortable with using a command line program).

I’ve enhanced the MIDITONES program to allow converting a MIDI SMF file to AruduboyTones format, in addition to its original purpose of converting to the Playtune format (used in the current Arduboy library). I just haven’t announced it yet (so I guess this can be considered the announcement :slight_smile:)

Len Shustek, the author of MIDITONES, didn’t wish to include my enhancements in his program but is fine with me creating a fork. My program is called midi2tones and can be found here:

ArduboyTones is now easier to install. It’s now available in the Arduino IDE library manager.

  • In the Arduino IDE select from the menus: Sketch > Include Library > Manage Libraries...
  • In the Library Manager Filter your search… field enter arduboytones.
  • Click somewhere within the ArduboyTones entry.
  • Click on the Install button.

The Arduboy2 library is also now installable via the Library Manager in the same way.

For more library installation information see

Installing Additional Arduino Libraries - Using the Library Manager

1 Like

That’s bad ass dude. I had not realized that you forked Miditones :smiley:

I’ll take a look and see if this helps us =).

Thanks a ton, Scott!

1 Like

It just hit me that Tones & Tunes are not compatible.

Seems that MIDI2Tones creates a byte stream, where sound.tones() requires uint16.

My hopes was that tones() would allow me to 1) play tunes in the background, 2) play up to 3 tones in sequence to create sound effects (something that Tunes can’t do).

ArduboyTones is a bit more limited than ArduboyPlaytune with respect to playing background music and sound effects at the same time. However:

  1. It can play tunes in the background. The tune must be monotonic, whereas ArduobyPlaytune can play two voice polyphonic.

  2. You can play effects of up to 3 tones (or more using an array) but it will stop whatever sound (background music or other effect) is currently playing. You can use the playing() function to know when the effect has ended and then restart the background music. Unfortunately, each time you do this the background music will start from the beginning.

I wrote ArduboyTones to be very small, simple and efficient. It wasn’t really intended to allow both background music and effects at the same time. I figured ArduboyPlaytune served that purpose, at the expense of larger code size and causing problems with the RGB LED.

1 Like

midi2tones can create either a Playtune compatible byte stream or the “frequency/duration pair” stream used by ArduboyTones.

For ArduobyTones compatible output you use the -o2 command line option.

1 Like

Shit dude. Apologies for missing the -o2 switch.

I’ll play w/ it. :grin:

This is the monster we’re working on.


Dear all,
Sorry to be a pain, I am trying to understand why most piezo sounders have a signal wire for PWM and a ground and the Arduboy has two signal wires with 2 x PWM in sync (I had a look at the signal on a scope today). How does this work? I know from the forums you created some clever code to raise the volume. Please advise.

I am a teacher and have been asked by a student!

Steve Daly

1 Like

This might help …

1 Like

That article not very relevant to the question. A real Arduboy does have a non-typical piezo speaker, with two ceramic elements; one on each side of the flexible metal disc. A standard piezo transducer has only a single element on one side of the metal disc. When driven properly, a dual element disc can produce more volume for the same size as a single element but the way the Arduboy is wired it only makes use of one of the elements (so a single sided disc could have been used, and is for most homemade designs).

I think this post of mine better explains the use of two pins:


Thanks guys, this information is very useful in understanding the operation of the circuit, thank you kindly for the explanation, I’ll forward it on to the students.


Hi sorry to bother you. I took a scope reading during playing Picovaders and got channel 1 and 2 trace one each pin of the piezo buzzer. See picture. I wonder if I made a mistake as I would have expected so see one of the signals inverted? Any idea?

Note that there is a 220 ohm resistor between the signal coming from Arduino Pin 5 (ATmega32U4 pin 31) and the buzzer lead that it drives. (It’s shown as capacitor C12 in the schematic but it’s populated with a resistor.) Therefore, if you’re scoping that buzzer lead itself, you are probably seeing an attenuated version of the other buzzer lead.

With Picovaders, Pin 5 is held at low and only Pin 13 is driven with an audio signal.

To look at the Pin 5 output, you can put your probe on the microprocessor side of the resistor, as circled in green in this photo:


1 Like

Thanks Scott, that makes sense. I will have a go and get back to you! Thank you very much for your time. Greatly appreciated.

Would you please provide a simple, complete example? Is it possible to query the parameter to find out what audio the arduboy is currently playing?

Do you mean an example of using the ArduboyTones library?

#include <Arduboy2.h>
#include <ArduboyTones.h>

Arduboy2 arduboy;
ArduboyTones sound(;

void setup() {

void loop() {
  sound.tone(NOTE_C3,500, NOTE_D3,250, NOTE_E3,1000);
  arduboy.delayShort(2000); // the tones will be playing during this delay

No. The Arduboy2 audio functions are only to provide control of muting or unmuting sound.

You can use the ArduboyTones playing() function to determine if something is currently playing but not what tone is playing or for how long.

Your example doesn’t play any audio on my DIY arduboy where the speaker is on Pro Micro pin D5.

It should, as long as the other side of the speaker is connected to ground (or the proper pin 13, which isn’t available on a Pro Micro).

Does sound work for any other sketches? If not, maybe sound is muted. To unmute, Hold B while powering up and press UP while still holding B, then release both. (Pressing DOWN instead of UP will mute.)

I optimized the ArduboyTones library interrupt service routine by ~52 bytes :slight_smile:

Since my version of the library also has additional changes for the Homemade package I just give a link to the changes here:

I shall update the FX version too!