Introduction: Intel Edison: Custom Doorbell

About: 31 years old tinker and diy hobbyist. From Oulu, Finland. IG @mkarvonen_instructables

Have you ever wondered that the old fashion "ding dong" sound in your doorbell is boring?

I have an solution for you!

Customized doorbell that will play the sound on your choice!

The tune is played in an old fashion Ring Tone Text Transfer Language (RTTTL).

If the RTTTL doesn't ring a bell... It is the good old monotonic ringtones. That's right. You can even play your own compositions in your doorbell.

You will need a library to the project called pitches.h.

The library can be found here.

Remember to watch the video for sound examples!!!

To support my projects view the video on my Youtube channel :)

(For mobile users press HERE to watch the video)

Step 1: The RTTTL

Ring Tone Text Transfer Language (RTTTL) was developed by Nokia and it is divided to 3 parts.

"tetris:d=4,o=5,b=160:e6,8b,8c6,8d6,16e6,16d6,8c6,8b,a,8a,8c6,e6,8d6,8c6,b,8b,8c6,d6,e6,c6,a,2a,8p,d6,8f6,a6,8g6,8f6,e6,8e6,8c6,e6,8d6,8c6,b,8b,8c6,d6,e6,c6,a,a";

Part 1: name of the ringtone a string of characters represents the name of the ringtone. Like in this the name is "tetris"

Part 2: settings, where "d=" is the default duration of a note.

"o=" is the default octave. And "b=" is the tempo, in "beats per minute".

Part 3: the notes. Each note is separated by a comma and includes, in sequence: a duration specifier and a standard music note.

Step 2: Components and Prototype

This project is made for Intel Edison but any Arduino board should do fine.

You will need some cables, A small speaker and a push button. I did my own shield for this project on a proto shield but that is optional.

Step 3: Soldering the Proto Shield

Solder the pins for the speaker and push button to the board.

Then solder needed jumper wires.

And lastly remember to put 10 kOhm resistor to the push button "in signal" and ground it. The button won't work without it.

Follow the code to get the right pins to the right place.

But if you are not familiar with reading the code, the speaker goes to pin 8 and the other goes to ground. The push button goes to pin 7 and the other end goes to Vcc (+5v). Solder the resistor between pin 7 and GND.

Step 4: Coding.

This code needs a separate library.

First define and include everything important. Also set the global variables and notes.

<p>#include "pitches.h"<br>int song;
int tonePin=8;   // Use pin 8 for your speaker
const int pinButton = 3; 
#define OCTAVE_OFFSET 0</p><p>int notes[] = { 0,
NOTE_C4, NOTE_CS4, NOTE_D4, NOTE_DS4, NOTE_E4, NOTE_F4, NOTE_FS4, NOTE_G4, NOTE_GS4, NOTE_A4, NOTE_AS4, NOTE_B4,
NOTE_C5, NOTE_CS5, NOTE_D5, NOTE_DS5, NOTE_E5, NOTE_F5, NOTE_FS5, NOTE_G5, NOTE_GS5, NOTE_A5, NOTE_AS5, NOTE_B5,
NOTE_C6, NOTE_CS6, NOTE_D6, NOTE_DS6, NOTE_E6, NOTE_F6, NOTE_FS6, NOTE_G6, NOTE_GS6, NOTE_A6, NOTE_AS6, NOTE_B6,
NOTE_C7, NOTE_CS7, NOTE_D7, NOTE_DS7, NOTE_E7, NOTE_F7, NOTE_FS7, NOTE_G7, NOTE_GS7, NOTE_A7, NOTE_AS7, NOTE_B7
};</p>

Then write the songs that you want for to be played. This example has got 30 different songs to choose from. The code looks messy but as you can see there is the char*song1 etc After the = mark there is the name of the song.

<p>char *song1 = "The Simpsons:d=4,o=5,b=160:c.6,e6,f#6,8a6,g.6,e6,c6,8a,8f#,8f#,8f#,2g,8p,8p,8f#,8f#,8f#,8g,a#.,8c6,8c6,8c6,c6";<br></p><p>char *song2 = "Indiana:d=4,o=5,b=250:e,8p,8f,8g,8p,1c6,8p.,d,8p,8e,1f,p.,g,8p,8a,8b,8p,1f6,p,a,8p,8b,2c6,2d6,2e6,e,8p,8f,8g,8p,1c6,p,d6,8p,8e6,1f.6,g,8p,8g,e.6,8p,d6,8p,8g,e.6,8p,d6,8p,8g,f.6,8p,e6,8p,8d6,2c6";
</p><p>char *song3 = "TakeOnMe:d=4,o=4,b=160:8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5,8f#5,8e5,8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5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,b,32p,b,32p,b,32p,b,32p,g#,32p,a,32p,b,8p,b,b,2b,4p,8e,8g#,8b,1c#6,8f#,8a,8c#6,1e6,8a,8c#6,8e6,1e6,8b,8g#,8a,2b";
</p><p>char *song9 = "Bond:d=4,o=5,b=80:32p,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d#6,16d#6,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d6,16c#6,16c#7,c.7,16g#6,16f#6,g#.6";
</p><p>char *song10 = "MASH:d=8,o=5,b=140:4a,4g,f#,g,p,f#,p,g,p,f#,p,2e.,p,f#,e,4f#,e,f#,p,e,p,4d.,p,f#,4e,d,e,p,d,p,e,p,d,p,2c#.,p,d,c#,4d,c#,d,p,e,p,4f#,p,a,p,4b,a,b,p,a,p,b,p,2a.,4p,a,b,a,4b,a,b,p,2a.,a,4f#,a,b,p,d6,p,4e.6,d6,b,p,a,p,2b";
</p><p>char *song11 = "StarWars:d=4,o=5,b=45:32p,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#.6,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#6";
</p><p>char *song12 = "GoodBad:d=4,o=5,b=56:32p,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,d#,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,c#6,32a#,32d#6,32a#,32d#6,8a#.,16f#.,32f.,32d#.,c#,32a#,32d#6,32a#,32d#6,8a#.,16g#.,d#";
</p><p>char *song13 = "TopGun:d=4,o=4,b=31:32p,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,16f,d#,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,g#";
</p><p>char *song14 = "A-Team:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#";
</p><p>char *song15 = "Flinstones:d=4,o=5,b=40:32p,16f6,16a#,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,d6,16f6,16a#.,16a#6,32g6,16f6,16a#.,32f6,32f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,a#,16a6,16d.6,16a#6,32a6,32a6,32g6,32f#6,32a6,8g6,16g6,16c.6,32a6,32a6,32g6,32g6,32f6,32e6,32g6,8f6,16f6,16a#.,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#6,16c7,8a#.6";
</p><p>char *song16 = "Jeopardy:d=4,o=6,b=125:c,f,c,f5,c,f,2c,c,f,c,f,a.,8g,8f,8e,8d,8c#,c,f,c,f5,c,f,2c,f.,8d,c,a#5,a5,g5,f5,p,d#,g#,d#,g#5,d#,g#,2d#,d#,g#,d#,g#,c.7,8a#,8g#,8g,8f,8e,d#,g#,d#,g#5,d#,g#,2d#,g#.,8f,d#,c#,c,p,a#5,p,g#.5,d#,g#";
</p><p>char *song17 = "Gadget:d=16,o=5,b=50:32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,32d#,32f,32f#,32g#,a#,d#6,4d6,32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,8d#";
</p><p>char *song18 = "Smurfs:d=32,o=5,b=200:4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8f#,p,8a#,p,4g#,4p,g#,p,a#,p,b,p,c6,p,4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8b,p,8f,p,4f#";
</p><p>char *song19 = "MahnaMahna:d=16,o=6,b=125:c#,c.,b5,8a#.5,8f.,4g#,a#,g.,4d#,8p,c#,c.,b5,8a#.5,8f.,g#.,8a#.,4g,8p,c#,c.,b5,8a#.5,8f.,4g#,f,g.,8d#.,f,g.,8d#.,f,8g,8d#.,f,8g,d#,8c,a#5,8d#.,8d#.,4d#,8d#.";
</p><p>char *song20 = "LeisureSuit:d=16,o=6,b=56:f.5,f#.5,g.5,g#5,32a#5,f5,g#.5,a#.5,32f5,g#5,32a#5,g#5,8c#.,a#5,32c#,a5,a#.5,c#.,32a5,a#5,32c#,d#,8e,c#.,f.,f.,f.,f.,f,32e,d#,8d,a#.5,e,32f,e,32f,c#,d#.,c#";
</p><p>char *song21 = "MissionImp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d";//char *song = "smb:d=4,o=5,b=100:16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,8p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,16p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16c7,16p,16c7,16c7,p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16d#6,8p,16d6,8p,16c6";
</p><p>char *song22 = "SMBUndergr:d=16,o=6,b=100:c,c5,a5,a,a#5,a#,2p,8p,c,c5,a5,a,a#5,a#,2p,8p,f5,f,d5,d,d#5,d#,2p,8p,f5,f,d5,d,d#5,d#,2p,32d#,d,32c#,c,p,d#,p,d,p,g#5,p,g5,p,c#,p,32c,f#,32f,32e,a#,32a,g#,32p,d#,b5,32p,a#5,32p,a5,g#5";
</p><p>char *song23 = "SMBWater:d=8,o=6,b=250:4d5,4e5,4f#5,4g5,4a5,4a#5,b5,b5,b5,p,b5,p,2b5,p,g5,2e.,2d#.,2e.,p,g5,a5,b5,c,d,2e.,2d#,4f,2e.,2p,p,g5,2d.,2c#.,2d.,p,g5,a5,b5,c,c#,2d.,2g5,4f,2e.,2p,p,g5,2g.,2g.,2g.,4g,4a,p,g,2f.,2f.,2f.,4f,4g,p,f,2e.,4a5,4b5,4f,e,e,4e.,b5,2c.";
</p><p>char *song24 = "smbdeath:d=4,o=5,b=90:32c6,32c6,32c6,8p,16b,16f6,16p,16f6,16f.6,16e.6,16d6,16c6,16p,16e,16p,16c"; 
</p><p>char *song25 = "tk3jin:d=4,o=5,b=125:16f#4,16e4,8f#4,8a4,16f#4,16e4,8f#4,8a4,16f#4,16e4,16f#4,16p,16f#4,16e4,8f#4,8a4,16f#4,16e4,16f#4,16e4,16c,16e4,16b4,16e4,16a4,16f#4,16f#4,16e4,8f#4,8a4,16f#4,16e4,8f#4,8a4,16f#4,16e4,16f#4,16p,16f#4,16e4,8f#4,8a4,16f#4,16e4,16f#4,16e4,16c,16e4,16b4,16e4,16a4,16f#4,16p";
</p><p>char *song26 = "doom_map:d=4,o=5,b=80:16e4,16g4,16e4,16e4,16e4,16f#4,16e4,16e4,16e4,16a#4,16e4,16a4,16e4,16g4,16e4,16e4,16e4,16g4,16e4,16e4,16e4,16f#4,16e4,16e4,16e4,16a#4,16e4,16a4,16e4,16g4,16e4,16f#4,16g4,16a#4,16g4,16g4,16g4,16c,16g4,16g4,16g4,16c#,16g4,16c,16g4,16a#4,16g4,16g4,16g4,16a#4,16g4,16g4,16g4,16c,16g4,16g4,16g4,16c#,16g4,16c,16g4,8a#4";
</p><p>char *song27 = "duke:d=4,o=5,b=90:16f#4,16a4,16p,16b4,8p,16f#4,16b4,16p,16c#,8p,16f#4,16c#,16p,16d,16p,16f#4,16p,8c#,16b4,16a4,16f#4,16e4,16f4,16f#4,16g4,16b4,16a4,16g4,16f#4,16a4,16p,16f#4,16a4,16p,16b4,8p,16f#4,16b4,16p,16c#,8p,16f#4,16c#,16p,16d,16p,16f#4,16p,8c#,16b4,16a4,16f#4,16e4,16f4,16f#4,16g4,16b4,16a4,16g4,16f#4,16a4";
</p><p>char *song28 = "tetris:d=4,o=5,b=160:e6,8b,8c6,8d6,16e6,16d6,8c6,8b,a,8a,8c6,e6,8d6,8c6,b,8b,8c6,d6,e6,c6,a,2a,8p,d6,8f6,a6,8g6,8f6,e6,8e6,8c6,e6,8d6,8c6,b,8b,8c6,d6,e6,c6,a,a";
</p><p>char *song29 = "smb3lvl1:d=4,o=5,b=80:16g,32c,16g.,16a,32c,16a.,16b,32c,16b,16a.,32g#,16a.,16g,32c,16g.,16a,32c,16a,4b.,32p,16c6,32f,16c.6,16d6,32f,16d.6,16e6,32f,16e6,16d.6,32c#6,16d.6,16c6,32f,16c.6,16d6,32f,16d6,4e.6,32p,16g,32c,16g.,16a,32c,16a.,16b,32c,16b,16a.,32g#,16a.,16c6,8c.6,32p,16c6,4c.6";
</p><p>char *song30 = "addams:d=4,o=5,b=160:8c,8d,8e,8f,1p,8d,8e,8f#,8g,1p,8d,8e,8f#,8g,p,8d,8e,8f#,8g,p,8c,8d,8e,8f,1p,8c,f,8a,f,8c,b4,g.,8f,e,8g,e,8c,a4,f.,8c,f,8a,f,8c,b4,g.,8f,e,8c,d,8e,2f";</p>

Then its time for setup. This code stays the same pretty much every time. Also there is setup for Serial and pinButton input.

<p>void setup()<br>{
  Serial.begin(115200);
   pinMode(pinButton, INPUT);</p><p>}</p><p>#define isdigit(n) (n >= '0' && n <= '9')</p><p>void play_rtttl(char *p)
{
  </p><p>  byte default_dur = 4;
  byte default_oct = 6;
  int bpm = 63;
  int num;
  long wholenote;
  long duration;
  byte note;
  byte scale;</p><p>  while(*p != ':') p++;    
  p++;                     </p><p> 
  if(*p == 'd')
  {
    p++; p++;              
    num = 0;
    while(isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    if(num > 0) default_dur = num;
    p++;                   
  }</p><p>  Serial.print("ddur: "); Serial.println(default_dur, 10);</p><p> 
  if(*p == 'o')
  {
    p++; p++;              
    num = *p++ - '0';
    if(num >= 3 && num <=7) default_oct = num;
    p++;                   
  }</p><p>  Serial.print("doct: "); Serial.println(default_oct, 10);</p><p>  
  if(*p == 'b')
  {
    p++; p++;              
    num = 0;
    while(isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    bpm = num;
    p++;                   
  }</p><p>  Serial.print("bpm: "); Serial.println(bpm, 10);</p><p>  
  wholenote = (60 * 1000L / bpm) * 4;  </p><p>  Serial.print("wn: "); Serial.println(wholenote, 10);</p><p>  
  while(*p)
  {
    
    num = 0;
    while(isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    
    if(num) duration = wholenote / num;
    else duration = wholenote / default_dur;  </p><p>   
    note = 0;</p><p>    switch(*p)
    {
      case 'c':
        note = 1;
        break;
      case 'd':
        note = 3;
        break;
      case 'e':
        note = 5;
        break;
      case 'f':
        note = 6;
        break;
      case 'g':
        note = 8;
        break;
      case 'a':
        note = 10;
        break;
      case 'b':
        note = 12;
        break;
      case 'p':
      default:
        note = 0;
    }
    p++;</p><p>    
    if(*p == '#')
    {
      note++;
      p++;
    }</p><p>    
    if(*p == '.')
    {
      duration += duration/2;
      p++;
    }
  
   
    if(isdigit(*p))
    {
      scale = *p - '0';
      p++;
    }
    else
    {
      scale = default_oct;
    }</p><p>    scale += OCTAVE_OFFSET;</p><p>    if(*p == ',')
      p++;       </p><p>    if(note)
    {
      Serial.print("Playing: ");
      Serial.print(scale, 10); Serial.print(' ');
      Serial.print(note, 10); Serial.print(" (");
      Serial.print(notes[(scale - 4) * 12 + note], 10);
      Serial.print(") ");
      Serial.println(duration, 10);
      tone(tonePin,notes[(scale - 4) * 12 + note]);
      delay(duration);
        noTone(8);
    }
    else
    {
      Serial.print("Pausing: ");
      Serial.println(duration, 10);
      delay(duration);
    }
  }
}</p>

Then its time for loop. In here you can choose what song is played when the button is pressed. After the song ends the Edison will start the wait for new button press. Also this all is printed to Serial monitor.

<p>void loop()<br>{
  if(digitalRead(pinButton)){</p><p>//Chance the "song29" to "song20" for example to get a different tune. The default in this code is SuperMarioBros 3 first level theme song.</p><p>
  play_rtttl(song29);
  
  Serial.println("Done.");
 
  }
}</p>

Step 5: Case for the Push Button.

The case is made from an old plastic case that i had laying around. I just cut a simple hole with a knife and glued the button in to the hole.

The lid that goes on the button is from another case.

Step 6: Case for the Edison and Speaker.

The case for the Edison and the speaker is made from old ADSL modem.

Simply just open the case and throw everything from the inside away and fit the speaker and Edison in to it.

Few simple modifications had to be done. For this i used a knife.

Step 7: Final Install and Testing

The final product is done.

The case is taped to the wall with two side tape and it holds good.

The tune can be chanced anytime. Just plug in the USB cable and load any song in that you want!

Search more songs that are made with RTTTL from Google. I'm sure there are thousands to chose from!

Now you just have to wait someone to come over!

(or you could just order pizza? )

If you like my project's be sure to follow me on instructables and on twitter @MiskaKarvonen

Protected Contest

Participated in the
Protected Contest

On a Budget Contest

Participated in the
On a Budget Contest

Homemade Gifts Contest

Participated in the
Homemade Gifts Contest