Arduino: Using my MelodyUtils library for R2-D2 style chirps

Posted by Dave Tucker on Mon 22 April 2013

As part of a small robotics project I've been working on this weekend (affectionately called CoBe1, there will be a follow up blog on that soon) I decided to give by robot some personality in the form a a voice, and uploaded some of my code to GitHub.

While Arduino is capable of playing music and sounds from an SD Card I wanted something a little more authentic… something similar to R2-D2's chirps from Star Wars. I had a mini 8Ohm speaker lying around and following the tutorials here it was easy to get it hooked up to my Arduino Uno and start making sounds. By adjusting the default melody and timings I got part way to achieving my R2-D2 style attitude, but notes on their own just didn't cut it. What I needed was some articulations. I got coding and whipped up a library that makes it easy to use glissando and tremolo. Want to give it a try? Grab the code on GitHub Here's a simple example sketch:

#include <pitches.h>;

void setup()
MelodyUtils mel(8);
mel.Glis(NOTE_C3, NOTE_C4, 5);
mel.Trem(NOTE_C3, 1000, 30);

void loop()

This is as far as I got this weekend. Next weekend I plan to add a few more articulations and finalise my R2-D2 style chirps. Watch this space!

tags: arduino, robotics

Comments !