Arduino Playing Grendizer Theme Song on Tinkercad

Intro

The best animation series of the 70’s and 80’s, Grendizer is played on Arduino using simple components and Tinkercad online Simulation environment. Who doesn’t love that?

If you’re new to Arduino or don’t yet know it, Arduino can play melodies using the tone() function with a simple Speaker.

Today, we’re going to learn how to assemble this simple circuit and play Grendizer Theme song on it and run it on Autodesk Tinkercad Simulation.

And even more, you can make your own Real circuit with REAL Arduino board and play the theme song Live.

You can even use the same setup to play any theme song or melody on Tinkercad or on Real Arduino board. Let’s get started.

surveyeah icon JOIN SURVEYEAH!

Components

As we are using Tinkercad Simulation, we don’t need to buy any components or even software. Tinkercad is a free online environment. It comes with many Arduino Boards, power supplies, sensors and actuators.

So, the only thing you need to use is to go www.tinkercad.com and build our circuits.

You may also want to build your real circuit so here are the needed components:

Arduino UNO board

8-ohm Speaker

Wires

9-volt Battery

Those are the components you’ll need on Tinkercad and also in the real world if you intend to build the physical circuit.

Circuit

Here, we are going to select the components in Tinkercad environment and connect them together.

Again, the same connection applies to the physical circuit.

First, we open Tinkercad.com

surveyeah icon JOIN SURVEYEAH!

Create new account if you don’t have one and Log in.

Then we select Circuits from the tab on the upper left of the screen.

Then, we have a blank sheet that we can place our circuit components.

You can see the search bar on the upper right. Here where you can type in your desired components.

We start by typing Arduino. We note that Arduino boards start to below the search bar. We select Arduino UNO board. Then we place it on the blank sheet.

Then, we write Speaker. We find the Speaker appears and we select it and we place it.

You can connect the circuit using wires. Wires are connected on Tinkercad software using click on the desired pin and hold it to the other pin.

Now, we connect the Speaker to the Arduino UNO board. We connect one Speaker pin to Arduino PIN 12 and the other Speaker pin to Arduino GND pin.

Now we’ve completed the circuit connection on Tinkercad.

Software

Here is the code that uses tone() function.


// Watch Video https://youtu.be/kY0EgTAXP3g
// http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation
// http://ringtone.vulc.in/Default.aspx
const int tonePin = 12;  
#define OCTAVE_OFFSET 0
// These values can also be found as constants in the Tone library (Tone.h)
int notes[] = { 0,
262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494,
523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988,
1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976,
2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951
};
const char songa[] PROGMEM = "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";
const char songb[] PROGMEM = "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";
const char songc[] PROGMEM = "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,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5";
const char songd[] PROGMEM = "Entertainer:d=4,o=5,b=140:8d,8d#,8e,c6,8e,c6,8e,2c.6,8c6,8d6,8d#6,8e6,8c6,8d6,e6,8b,d6,2c6,p,8d,8d#,8e,c6,8e,c6,8e,2c.6,8p,8a,8g,8f#,8a,8c6,e6,8d6,8c6,8a,2d6";
const char songe[] PROGMEM = "Muppets:d=4,o=5,b=250:c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,8a,8p,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,8e,8p,8e,g,2p,c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,a,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,d,8d,c";
const char songf[] PROGMEM = "Xfiles:d=4,o=5,b=125:e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,g6,f#6,e6,d6,e6,2b.,1p,g6,f#6,e6,d6,f#6,2b.,1p,e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,e6,2b.";
const char songg[] PROGMEM = "Looney:d=4,o=5,b=140:32p,c6,8f6,8e6,8d6,8c6,a.,8c6,8f6,8e6,8d6,8d#6,e.6,8e6,8e6,8c6,8d6,8c6,8e6,8c6,8d6,8a,8c6,8g,8a#,8a,8f";
const char songh[] PROGMEM = "20thCenFox:d=16,o=5,b=140:b,8p,b,b,2b,p,c6,32p,b,32p,c6,32p,b,32p,c6,32p,b,8p,b,b,b,32p,b,32p,b,32p,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";
const char songi[] PROGMEM = "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";
const char songj[] PROGMEM = "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";
const char songk[] PROGMEM = "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";
const char songl[] PROGMEM = "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#";
const char songm[] PROGMEM = "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#";
const char songn[] PROGMEM = "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#";
const char songo[] PROGMEM = "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";
const char songp[] PROGMEM = "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#";
const char songq[] PROGMEM = "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#";
const char songr[] PROGMEM = "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#";
const char songs[] PROGMEM = "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#.";
const char songt[] PROGMEM = "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#";
const char songu[] PROGMEM = "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";
const char songv[] PROGMEM = "TMNT:d=4,o=5,b=100:8e,8f#,8e,8f#,8e,16f#,8e.,8f#,8g,8a,8g,8a,8g,16a,8g.,8a,8c6,8d6,8c6,8d6,8c6,16d6,8c.6,8d6,16a,16a,16a,16a,8g,8a,8p,16a,16a,16a,16a";
const char songw[] PROGMEM = "BackFuture:d=4,o=5,b=160:32p,p,8c.,16p,g,16p,16c.6,16p,a#.,16p,16a,16p,16g,16p,8a,16p,8g,16p,8f,16p,1g.,1p,g.,16p,c.,16p,2f#.,16p,32g.,32p,32a.,32p,8g,32p,8e,32p,8c,32p,f#,16p,32g.,32p,32a.,32p,8g.,32p,8d.,32p,8g.,32p,8d.6,32p,d6,16p,c#6,16p,32b.,32p,32c#.6,32p,2d6";
const char songx[] PROGMEM = "Thriller:d=8,o=5,b=112:b,d6,b,e6,16p,2d6,4p,d6,16p,c#6,16p,b,4p,p,b,b,32a,16p,32p,a,16g,g,16p,e,g,a,b,a,a,16g,b";
const char songy[] PROGMEM = "Goldorak:d=4,o=5,b=140:8c#,f#,8p,8c#,a,p,8b,8a,8g#,8f#,g#,8c#,8c#,f,8p,8c#,b,p,8a.,16p,8g#.,16p,f#,p,g#.,8g#,g#,a,b,a,g#.,8p,8f#,8p,8f#,8p,8a,8p,8b,8p,1c#6,d6.,16c#6.,32p,b.,8p,16a.,32p,8a,8p,8f#,c#6.,8p,b,a,g#,8p,8f#,2g#.,p,a,8p,16a.,32p,g#,f#,b,c#6,2d6,c#6,b,g#.,8a,1f#,a#,a#,g#.,8f#,8f,f,8f,2c#6,d#6,8d#6,8c#6,a#.,8b,1g#,b.,16b.,32p,a#,g#,8d#6,c#6,8a#,f#.,8p,g#,16d#6.,32p,16d#6.,32p,c#6,f,2f#.";
const char *allsongs[] = {songa,
songb, 
songc,
songd, 
songe, 
songf, 
songg, 
songh, 
songi, 
songj, 
songk, 
songl, 
songm, 
songn, 
songo, 
songp, 
songq, 
songr, 
songs, 
songt, 
songu,
songv,
songw,      
songx,
songy
};
void setup(void)
{
Serial.begin(9600);
}
#define isdigit(n) (n >= '0' && n <= '9')
void play_rtttl(const char *signMessage)
{
byte default_dur = 4;
byte default_oct = 6;
int bpm = 63;
int num;
long wholenote;
long duration;
byte note;
byte scale;
int pauses = 2;
int p = 0;
while(pgm_read_byte_near(signMessage + p) != ':') p++;    // ignore name
p++;                     // skip ':'
// get default duration
if(pgm_read_byte_near(signMessage + p) == 'd')
{
p++; p++;              // skip "d="
num = 0;
while(isdigit(pgm_read_byte_near(signMessage + p)))
{
num = (num * 10) + (pgm_read_byte_near(signMessage + p++) - '0');
}
if(num > 0) default_dur = num;
p++;                   // skip comma
}
Serial.print("ddur: "); Serial.println(default_dur, 10);
// get default octave
if(pgm_read_byte_near(signMessage + p) == 'o')
{
p++; p++;              // skip "o="
num = pgm_read_byte_near(signMessage + p++) - '0';
if(num >= 3 && num <=7) default_oct = num;
p++;                   // skip comma
}
Serial.print("doct: "); Serial.println(default_oct, 10);
// get BPM
if(pgm_read_byte_near(signMessage + p) == 'b')
{
p++; p++;              // skip "b="
num = 0;
while(isdigit(pgm_read_byte_near(signMessage + p)))
{
num = (num * 10) + (pgm_read_byte_near(signMessage + p++) - '0');
}
bpm = num;
p++;                   // skip colon
}
Serial.print("bpm: "); Serial.println(bpm, 10);
// BPM usually expresses the number of quarter notes per minute
wholenote = (60 * 1000L / bpm) * 4;  // this is the time for whole note (in milliseconds)
Serial.print("wn: "); Serial.println(wholenote, 10);
// now begin note loop
while(pgm_read_byte_near(signMessage + p))
{
// first, get note duration, if available
num = 0;
while(isdigit(pgm_read_byte_near(signMessage + p)))
{
num = (num * 10) + (pgm_read_byte_near(signMessage + p++) - '0');
}
if(num) duration = wholenote / num;
else duration = wholenote / default_dur;  // we will need to check if we are a dotted note after
// now get the note
note = 0;
switch(pgm_read_byte_near(signMessage + 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++;
// now, get optional '#' sharp
if(pgm_read_byte_near(signMessage + p) == '#')
{
note++;
p++;
}
// now, get optional '.' dotted note
if(pgm_read_byte_near(signMessage + p) == '.')
{
duration += duration/2;
p++;
}
// now, get scale
if(isdigit(pgm_read_byte_near(signMessage + p)))
{
scale = pgm_read_byte_near(signMessage + p) - '0';
p++;
}
else
{
scale = default_oct;
}
scale += OCTAVE_OFFSET;
if(pgm_read_byte_near(signMessage + p) == ',')
p++;       // skip comma for next note (or we may be at the end)
// now play the note
if(note)
{
tone(tonePin, notes[(scale - 4) * 12 + note]);
delay(duration);
noTone(tonePin);
}
else
{
delay(duration);
if(!pauses && duration) return;
if(duration > 950) pauses--; 
}
}
}
char c;
void loop(void)
{
play_rtttl(allsongs[24]);
}

Now, we need to program Arduino UNO board inside Tinkercad environment with this code to start executing it.

On the upper right Code tab, click the dropdown menu and select the text only. When you’re prompted to the caution that you are going to deleted all the Blocks , you click Continue.

Then you paste the above code in the software sheet.

Now, you’re ready to start the circuit execution.

Simulation

Now, click the Start Simulation button to start the simulation.

You see that Arduino is connected to the USB port on the screen and it indicates that it’s powered and started software execution.

If all the steps are correctly followed, the Speaker starts to play Grendizer Theme song.

Congratulations, you’ve just built Arduino circuit that plays tones of your favorite Animation on Tinkercad.

Now you can build the circuit using real components.

https://www.tinkercad.com/things/cPmFW1AdSvZ

You can watch the video and subscribe to my channel.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top