Animal Sounds

Sound is a very personal part of a project. Everyone has their particular vision of how something sounds.

To experiment with sounds, the sound creation program below may be used. The program comes with several pre-programmed sounds:

  • A bird chirp
  • Cat meows (a meeee-ow, a me-oooow, and a mew)
  • Dog sounds (ruff and arf)

Ruff or woof are conventional representations in the English language of the barking of a dog. Onomatopoeia or imitative sounds, vary in other cultures: people "hear" a dog's barks differently and represent them in their own ways. Some of the equivalents of "woof" in other European and Asian languages are in Wikipedia. You can hear different sounds at the wonderful website

Part of the creative process is making your animal sound like what you believe it should sound like. This will probably involve a fair amount of experimentation. Sampled real sounds take up too much memory for Trinket and a ROM takes too many microcontroller pins. So the method used here is turning a digital pin on and off very fast to make sounds at various frequencies.

If you have an Arduino Uno/Leonardo/Mega/etc. handy, you can use a serial monitor to select frequencies using a potentiometer and see the values on the serial monitor. If you have a Trinket, you can listen to a tone but not see the output frequency easily.

You can add frequency / duration values together to make more complex sounds. You can also vary a tone up or down to get effects you want. Map out your sound into component sounds, for example "meow" for a cat. Start with the M sound: use the varyFrequency function to find a "mmm" (maybe 5100). The sound is short so we try 50 milliseconds. The "e" is "eeee", lasts longer, so the frequency 394 sounded right and the sound is longer so trial and error got 180 milliseconds. The "o" is a more complex sound, starting high (990) and getting a bit lower (1022). How long you run the loop and specify the duration for each sound will vary the sound. Finally "w" is enough like "m" that I repeat it as I could find no better sound. That is meeeow. You can also see meoooow and mew as variations. You may feel they do not sound enough cat-like which is ok, you can define your purr-fect sound using these methods.
Download: file
  Adafruit Animal - Sound testing module
  Works on Arduino Uno, Leonardo, Mega, Menta, etc.
  can work on Trinket with right pin mapping and no Serial port

// pins
#define SPEAKER   11   // Piezo Speaker pin (positive, other pin to ground)
#define POT       A0   // for Trinket, use 1 for #2, 3 for #3, 2 for #4
                       //   for Uno/Leo/Mega A0 to A5
// define serial if using debug on Uno/Leo/Mega, Trinket/Gemma comment out
#define SERIAL    
void setup() {
#ifdef SERIAL
  pinMode(SPEAKER,OUTPUT);  // important to set pin as output
void loop()  {
//  varyFrequency();  // uncomment to search for correct tone value
// the sounds below are defined - comment out those you do not want or
//   comment out if using varyFrequency() to select play with tones
// scale();  // if you would like to hear the whole frequency
             //   range, you can use this function
void varyFrequency() {   
//  use potentiometer to produce one tone per value of pot
//  good for getting pitch value to use in making sound routines
  int reading;
  const uint8_t scale = 1; // 1 for high frequencies, scale up to 15 for lowest freqs

  reading = scale * analogRead(POT);
  playTone(reading, 1000);
#ifdef SERIAL
  Serial.print("Freq = ");

void chirp() {  // Bird chirp
  for(uint8_t i=200; i>180; i--)

void meow() {  // cat meow (emphasis ow "me")
  uint16_t i;
  playTone(5100,50);        // "m" (short)
  playTone(394,180);        // "eee" (long)
  for(i=990; i<1022; i+=2)  // vary "ooo" down
  playTone(5100,40);        // "w" (short)

void meow2() {  // cat meow (emphasis on "ow")
  uint16_t i;
  playTone(5100,55);       // "m" (short)
  playTone(394,170);       // "eee" (long)
  delay(30);               // wait a tiny bit
  for(i=330; i<360; i+=2)  // vary "ooo" down
  playTone(5100,40);       // "w" (short)

void mew() {  // cat mew
  uint16_t i;
  playTone(5100,55);       // "m"   (short)
  playTone(394,130);       // "eee" (long)
  playTone(384,35);        // "eee" (up a tiny bit on end)
  playTone(5100,40);       // "w"   (short)

void ruff() {   // dog ruff
  uint16_t i;
  for(i=890; i<910; i+=2)     // "rrr"  (vary down)
  playTone(1664,150);         // "uuu" (hard to do)
  playTone(12200,70);         // "ff"  (long, hard to do)

void arf() {    // dog arf
  uint16_t i;
  playTone(890,25);          // "a"    (short)
  for(i=890; i<910; i+=2)    // "rrr"  (vary down)
  playTone(4545,80);         // intermediate
  playTone(12200,70);        // "ff"   (shorter, hard to do)

// play tone on a piezo speaker: tone shorter values produce higher frequencies
//  which is opposite beep() but avoids some math delay - similar to code by Erin Robotgrrl

void playTone(uint16_t tone1, uint16_t duration) {
  if(tone1 < 50 || tone1 > 15000) return;  // these do not play on a piezo
  for (long i = 0; i < duration * 1000L; i += tone1 * 2) {
     digitalWrite(SPEAKER, HIGH);
     digitalWrite(SPEAKER, LOW);

// another sound producing function similar to
void beep (int16_t frequencyInHertz, long timeInMilliseconds) {
    long x;	 
    long delayAmount = (long)(1000000/frequencyInHertz);
    long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
    for (x=0;x<loopTime;x++) {	 

void scale() {
  for(uint16_t i=50; i<15000; i++)  {
This guide was first published on Nov 21, 2013. It was last updated on Nov 21, 2013. This page (Animal Sounds) was last updated on Apr 23, 2019.