CRTC Electronics

Click here to edit subtitle

Wifi Pinewood Derby Car

Next generation of derby cars

Bread Boarding

This is the first step.  Make sure everything (code and hardware) is working the way you want it.

Soldering

once every thing is working on the bread board solder it all to gather. Make sure all the wires are just the right length.  Check to insure all is working. 

Stuffing

This can be the most difficult tasks.  Take your time, use hot glue to hold wire in to place and good luck.

Axels

If you don't have room to put the wheels on, you may use wooden dowels as axles giving you a little extra room.

Trobleshoot

It never works the first time. Take your time to figure out what's wrong and the tweaks you need to make it awesome.

Videos

Code

//192.168.4.1

#include <ESP8266WiFi.h>

#include <WiFiClient.h> 

#include <ESP8266WebServer.h>

#include "pitches.h"  

#include "melody.h"   

                                                                                                                  


ESP8266WebServer server(80);



const char *ssid = "The Goblin";

const char *password = "";



//PINs 

int green = 14;

int blue = 0;

int red = 4;

int faze = 1;

int ESP_Blue_Led = 2;

int speakerPin = 16;


int fadelevel = 0;

int fadeDirection = 0;

const long fadeInterval = 2;

unsigned long previousMillis = 0;

const long flashInterval = 100;


int espLedState = 1;

enum colors {_RED, _GREEN, _BLUE, _WHITE, _MAGENTA, _LBLUE, _YELLOW};

colors color = _RED;

enum lightStates {ON, OFF, FLASH, MX_FLASH, FADE};

lightStates lightState = OFF;


unsigned long noteStartTime = 0; 

int songNum = 0;

int notePosition = 1; //start at 1 not 0, 0 is the speed infro

int speed= melody[songNum][0]; //90; //15; //higher value, slower notes

unsigned long noteDuration = speed*noteDurations[songNum][notePosition]; //get the first duration







/*******************************************************************/


void setup() {

  ServerSetup();

  pinMode(speakerPin, OUTPUT); 

  pinMode(green, OUTPUT);

  pinMode(blue, OUTPUT);

  pinMode(red, OUTPUT);

  pinMode(ESP_Blue_Led, OUTPUT);


  //run the start up sounds and lights

  StartUpSoundsLights();

}



void loop() {

    server.handleClient();

    lights();

    sound();

}


/*******************************************************************/


void ServerSetup() {

    delay(1000);

    Serial.begin(115200);

    Serial.println();


    WiFi.softAP(ssid, password);


    IPAddress apip = WiFi.softAPIP();

    Serial.print("visit: \n");

    Serial.println(apip);

    server.on("/", handleRoot);

    server.on("/EspLedOn", handleBuiltInLedOn);

    server.on("/EspLedOff", handleBuiltInLedOff);

    server.on("/LedsOff", handleLedOff);

    server.on("/Flash", handleLedsFlash);

    server.on("/MX_Flash", handleLedsMX_Flash);

    server.on("/Fade", handleFade);

 

    server.on("/Red", handleRed);

    server.on("/Blue", handleBlue);

    server.on("/Green", handleGreen);

    server.on("/White", handleWhite);

    server.on("/Yellow", handleYellow);

    server.on("/LightBlue", handleLightBlue);

    server.on("/Magenta", handleMagenta);

    

    server.on("/PlaySong1", handlePlaySong1);

    server.on("/PlaySong2", handlePlaySong2);

    server.on("/PlaySong3", handlePlaySong3);

    server.on("/PlaySong4", handlePlaySong4);

    server.begin();

    Serial.println("HTTP server beginned");



    

}


/*******************************************************************/


void handleRoot() {

    webPage();

}


void handleBuiltInLedOn() {

  espLedState = 0;

 // digitalWrite(LED_BUILTIN, espLedState);

  webPage();

}


void handleBuiltInLedOff() {

  espLedState = 1;

 // digitalWrite(LED_BUILTIN, espLedState);

  webPage();

}


void handleLedOff() {

  lightState = OFF;

  webPage();

}


void handleLedsFlash() {

  allLEDsOFF();

  lightState = FLASH;

  webPage();

}


void handleLedsMX_Flash() {

  allLEDsOFF();

  lightState = MX_FLASH;

  webPage();

}

void handleFade() {

  allLEDsOFF();

  lightState = FADE;

  webPage();

}


void handleRed() {

  color = _RED;

  lightState = ON;

  webPage();

}

void handleBlue() {

  color = _BLUE;

  lightState = ON;

  webPage();

}

void handleGreen() {

  color = _GREEN;

  lightState = ON;

  webPage();

}

void handleWhite() {

  color = _WHITE;

  lightState = ON;

  webPage();

}

void handleYellow() {

  color = _YELLOW;

  lightState = ON;

  webPage();

}

void handleLightBlue() {

  color = _LBLUE;

  lightState = ON;

  webPage();

}

void handleMagenta() {

  color = _MAGENTA;

  lightState = ON;

  webPage();

}

   

void handlePlaySong1() {

  songNum = 1;

  webPage();

}

void handlePlaySong2() {

  songNum = 2;

  webPage();

}

void handlePlaySong3() {

  songNum = 3;

  webPage();

}

void handlePlaySong4() {

  songNum = 4;

  webPage();

}




/*******************************************************************/


void webPage(){

  String htmlCode; 

  htmlCode = "<html><head><style>body{background-color: #92BBBB}</style>";

  htmlCode += "<h1>Brown's ESP8266 AP WebServer</h1><br/>\n";

  

  if(espLedState == LOW){

    htmlCode += "<big>The ESP LED is now <b>ON</b></big><br/>\n";

  }else{

    htmlCode += "<big>The ESP LED is now <b>OFF</b></big><br/>\n";

  }

  htmlCode +=


    "<a href=\"EspLedOn\"><button style=\" width: 25%;\">Built-In-Led ON</button></a>"

    "<a href=\"EspLedOff\"><button style=\" width: 25%;\">Built-In-Led OFF</button></a><br/>"

    "<br/><br/>"

    

    "<big>RGB LEDs</big><br/>\n"

    "<a href=\"Red\"><button style=\" width: 7%; height: 5%;\">Red</button></a>"

    "<a href=\"Blue\"><button style=\" width: 7%; height: 5%;\">Blue</button></a>"

    "<a href=\"Green\"><button style=\"width: 7%; height: 5%;\">Green</button></a>"

    "<a href=\"White\"><button style=\"width: 7%; height: 5%;\">White</button></a>"

    "<a href=\"Yellow\"><button style=\" width: 7%; height: 5%;\">Yellow</button></a>"

    "<a href=\"LightBlue\"><button style=\"width: 7%; height: 5%;\">LightBlue</button></a>"

    "<a href=\"Magenta\"><button style=\" width: 7%; height: 5%;\">Magenta</button></a><br/>"

    "<br/>"

    "<a href=\"Fade\"><button style=\"display: block; width: 25%; height: 5%;\">Fade</button></a><br/>"

    "<a href=\"Flash\"><button style=\"display: block; width: 25%; height: 5%;\">Flash</button></a><br/>"

    "<a href=\"MX_Flash\"><button style=\"display: block; width: 25%; height: 5%;\">MIX Flash</button></a><br/>"

    "<a href=\"LedsOff\"><button style=\"display: block; width: 25%;height: 5%;\">Lights OFF</button></a><br/>"

    "<br/><br/>"

    "<big>Songs</big><br/>\n"

    "<a href=\"PlaySong1\"><button>Play Song 1</button></a>"

    "<a href=\"PlaySong2\"><button>Play Song 2</button></a>"

    "<a href=\"PlaySong3\"><button>Play Song 3</button></a>"

    "<a href=\"PlaySong4\"><button>Play Song 4</button></a><br/>"


;

   htmlCode += "</html>";


  server.send(200, "text/html", htmlCode);

}



 

void lights(){

  digitalWrite(ESP_Blue_Led, espLedState);

  

  if (lightState == OFF){

      digitalWrite(green, 0);

      digitalWrite(blue, 0);

      digitalWrite(red, 0);    

  }

  

   if (lightState == FLASH){

    unsigned long currentMillis = millis();

    if(currentMillis - previousMillis >= flashInterval) {

      previousMillis = currentMillis;   

      lightsFlashing();

    }

  } 

  if (lightState == MX_FLASH){

    unsigned long currentMillis = millis();

    if(currentMillis - previousMillis >= flashInterval) {

      previousMillis = currentMillis;   

      mxlightsFlashing();

    }

  } 


  if (lightState == FADE){

    unsigned long currentMillis = millis();

    if(currentMillis - previousMillis >= fadeInterval) {

      previousMillis = currentMillis;   

      lightsFading();

    }

  } 


  if (lightState == ON){

    if (color == _RED){

      digitalWrite(green, 0);

      digitalWrite(blue, 0);

      digitalWrite(red, 1); 

    }   

     if (color == _GREEN){

      digitalWrite(green, 1);

      digitalWrite(blue, 0);

      digitalWrite(red, 0); 

    }   

     if (color == _BLUE){

      digitalWrite(green, 0);

      digitalWrite(blue, 1);

      digitalWrite(red, 0); 

    }    

    if (color == _WHITE){

      digitalWrite(green, 1);

      digitalWrite(blue, 1);

      digitalWrite(red, 1);    

    }

    if (color == _YELLOW){

      digitalWrite(green, 1);

      digitalWrite(blue, 0);

      digitalWrite(red, 1);    

    }

    if (color == _LBLUE){

      digitalWrite(green, 1);

      digitalWrite(blue, 1);

      digitalWrite(red, 0);    

    }

    if (color == _MAGENTA){

      digitalWrite(green, 0);

      digitalWrite(blue, 1);

      digitalWrite(red, 1);    

    }

  }


}


void lightsFading()

{

  fadelevel+=fadeDirection;

 

  if (color == _RED) {

    analogWrite(red, fadelevel);

    Serial.print("RED.  Pin:");

    Serial.print(red);

    Serial.print(" FadeLevel:");

    Serial.print(fadelevel);

    Serial.print(" Direction:");

    Serial.println(fadeDirection);

    

    

  }

     

   if (color == _GREEN){

     analogWrite(green, fadelevel);

  }   

   if (color == _BLUE){

    analogWrite(blue, fadelevel);

  }    

  if (color == _WHITE){

      analogWrite(green, fadelevel);

      analogWrite(blue, fadelevel);

      analogWrite(red, fadelevel);    

  }

  if (color == _YELLOW){

      analogWrite(green, fadelevel);

      analogWrite(red, fadelevel);    

  }

  if (color == _LBLUE){

      analogWrite(green, fadelevel);

      analogWrite(blue, fadelevel);   

  }

  if (color == _MAGENTA){

      analogWrite(blue, fadelevel);

      analogWrite(red, fadelevel);    

  }

  

  if (fadelevel > 1020 ) fadeDirection=-1;

  if (fadelevel < 1 ) fadeDirection=1;


  

}






void mxlightsFlashing(){

  if (faze == 1){

      digitalWrite(green, 1);

      digitalWrite(blue, 0);

      digitalWrite(red, 1);   

  }

    if (faze == 2){

      digitalWrite(green, 0);

      digitalWrite(blue, 0);

      digitalWrite(red, 0);   

  }

    if (faze == 3){

      digitalWrite(green, 1);

      digitalWrite(blue, 0);

      digitalWrite(red, 1);   

  }

    if (faze == 4){

      digitalWrite(green, 0);

      digitalWrite(blue, 0);

      digitalWrite(red, 0);     

  }


    if (faze == 5){

      digitalWrite(green, 0);

      digitalWrite(blue, 1);

      digitalWrite(red, 0);    

  }

    if (faze == 6){

      digitalWrite(green, 0);

      digitalWrite(blue, 0);

      digitalWrite(red, 0);    

  }

    if (faze == 7){

      digitalWrite(green, 0);

      digitalWrite(blue, 1);

      digitalWrite(red, 0);    

  }

    if (faze == 8){

      digitalWrite(green, 0);

      digitalWrite(blue, 0);

      digitalWrite(red, 0);     

  }


    if (faze == 9){

      digitalWrite(green, 0);

      digitalWrite(blue, 0);

      digitalWrite(red, 0);    

      faze = 0;

  }   

  faze++;

}


void lightsFlashing(){

  int flashRed;

  int flashBlue;

  int flashGreen;

  

  if (color == _RED){

    flashRed = 1;

    flashBlue = 0;

    flashGreen = 0;

  }

  if (color == _BLUE){

    flashRed = 0;

    flashBlue = 1;

    flashGreen = 0;

  }

  if (color == _GREEN){

    flashRed = 0;

    flashBlue = 0;

    flashGreen = 1;

  }

  if (color == _WHITE){

    flashRed = 1;

    flashBlue = 1;

    flashGreen = 1;

  }

  if (color == _LBLUE){

    flashRed = 0;

    flashBlue = 1;

    flashGreen = 1;

  }

  if (color == _YELLOW){

    flashRed = 1;

    flashBlue = 0;

    flashGreen = 1;

  }

  if (color == _MAGENTA){

    flashRed = 1;

    flashBlue = 1;

    flashGreen = 0;

  }

  

  if (faze == 1){

    digitalWrite(red, flashRed);

    digitalWrite(blue, flashBlue);

    digitalWrite(green, flashGreen); 

  }

  if (faze == 2){

    digitalWrite(red, 0);

    digitalWrite(blue, 0);

    digitalWrite(green, 0);

  }

  if (faze == 3){

    digitalWrite(red, flashRed);

    digitalWrite(blue, flashBlue);

    digitalWrite(green, flashGreen);  

  }

  if (faze == 4){

    digitalWrite(red, 0);

    digitalWrite(blue, 0);

    digitalWrite(green, 0);

  }

  if (faze == 9){

    faze = 0;

  }   

  faze++;

}


void sound(){

  speed= melody[songNum][0];

  if (songNum){    

    unsigned long currentTime = millis();

    if (currentTime - noteStartTime >= noteDuration) {

      //play next note

      noteDuration = speed*noteDurations[songNum][notePosition];

      tone(speakerPin, melody[songNum][notePosition],noteDuration*.95);

      //pint to next note

      notePosition++;

      noteStartTime = millis();

    }

    if (melody[songNum][notePosition] == -1) {

      songNum = 0;

      noTone(speakerPin);

      notePosition = 1;// reset to first note

    }

  }

}


void StartUpSoundsLights(){


  digitalWrite(green, 1);

  digitalWrite(blue, 1);

  digitalWrite(red, 1);    

  tone(speakerPin, 600,200);

  delay(200);

  digitalWrite(green, 0);

  digitalWrite(blue, 0);

  digitalWrite(red, 0);    

  noTone(speakerPin);

  delay(300);

  digitalWrite(green, 1);

  digitalWrite(blue, 1);

  digitalWrite(red, 1);    

  tone(speakerPin, 600,200);

  delay(200);

  digitalWrite(green, 0);

  digitalWrite(blue, 0);

  digitalWrite(red, 0);    

  noTone(speakerPin);

}


void allLEDsOFF(){

        digitalWrite(green, 0);

      digitalWrite(blue, 0);

      digitalWrite(red, 0); 

}


melody.h

int melody[][300] = {

  {//nothing

    0,0, 

    },

  { // Mirio underground

    15,  //speed

    NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4,

    NOTE_AS3, NOTE_AS4, NO_SOUND,

    NO_SOUND,

    NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4,

    NOTE_AS3, NOTE_AS4, NO_SOUND,

    NO_SOUND,

    NOTE_F3, NOTE_F4, NOTE_D3, NOTE_D4,

    NOTE_DS3, NOTE_DS4, NO_SOUND,

    NO_SOUND,

    NOTE_F3, NOTE_F4, NOTE_D3, NOTE_D4,

    NOTE_DS3, NOTE_DS4, NO_SOUND,

    NO_SOUND, NOTE_DS4, NOTE_CS4, NOTE_D4,

    NOTE_CS4, NOTE_DS4,

    NOTE_DS4, NOTE_GS3,

    NOTE_G3, NOTE_CS4,

    NOTE_C4, NOTE_FS4, NOTE_F4, NOTE_E3, NOTE_AS4, NOTE_A4,

    NOTE_GS4, NOTE_DS4, NOTE_B3,

    NOTE_AS3, NOTE_A3, NOTE_GS3,

    NO_SOUND, NO_SOUND, NO_SOUND, END

  },

  {//test array

    2,/// speed

      // 1

    NOTE_A4, NOTE_AS4, NOTE_A4,  

    NOTE_A4, NOTE_AS4, NOTE_A4, NOTE_A4, 

    NOTE_AS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_GS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_A4, NOTE_AS4, NOTE_A4,  

    NOTE_A4, NOTE_AS4, NOTE_A4, NOTE_A4, 

    NOTE_AS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_GS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_G4, NOTE_GS4, NOTE_G4,  

    NOTE_G4, NOTE_GS4, NOTE_G4, NOTE_G4, 

    NOTE_GS4,NOTE_G4, NOTE_G4, NOTE_G4, 

    NOTE_FS4,NOTE_G4, NOTE_G4, NOTE_G4, 

    NOTE_G4, NOTE_GS4, NOTE_G4,  

    NOTE_G4, NOTE_GS4, NOTE_G4, NOTE_G4, 

    NOTE_GS4,NOTE_G4, NOTE_G4, NOTE_G4, 

    NOTE_FS4,NOTE_G4, NOTE_G4, NOTE_G4, 

    //2

    NOTE_A4, NOTE_AS4, NOTE_A4,  

    NOTE_A4, NOTE_AS4, NOTE_A4, NOTE_A4, 

    NOTE_AS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_GS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_A4, NOTE_AS4, NOTE_A4,  

    NOTE_A4, NOTE_AS4, NOTE_A4, NOTE_A4, 

    NOTE_AS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_GS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_G4, NOTE_GS4, NOTE_G4,  

    NOTE_G4, NOTE_GS4, NOTE_G4, NOTE_G4, 

    NOTE_GS4,NOTE_G4, NOTE_G4, NOTE_G4, 

    NOTE_FS4,NOTE_G4, NOTE_G4, NOTE_G4, 

    NOTE_G4, NOTE_GS4, NOTE_G4,  

    NOTE_G4, NOTE_GS4, NOTE_G4, NOTE_G4, 

    NOTE_GS4,NOTE_G4, NOTE_G4, NOTE_G4, 

    NOTE_FS4,NOTE_G4, NOTE_G4, NOTE_G4, 


    // solo 

    NOTE_A4, NOTE_AS4, NOTE_A4, NOTE_E5, 

    NOTE_A5, NOTE_AS5, NOTE_A5, NOTE_E5, 

    NOTE_A4, NOTE_AS4, NOTE_A4, NOTE_E5, NOTE_A5,NOTE_G5, 

    NOTE_A4, NOTE_AS4, NOTE_A4, NOTE_E5, 

    NOTE_A5, NOTE_AS5, NOTE_A5, NOTE_E5, 

    NOTE_A4, NOTE_AS4, NOTE_A4, NOTE_E5, NOTE_A5, NOTE_AS5, NOTE_G5, NOTE_A5,

    

    //3

    NOTE_A4, NOTE_AS4, NOTE_A4,  

    NOTE_A4, NOTE_AS4, NOTE_A4, NOTE_A4, 

    NOTE_AS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_GS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_A4, NOTE_AS4, NOTE_A4,  

    NOTE_A4, NOTE_AS4, NOTE_A4, NOTE_A4, 

    NOTE_AS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_GS4,NOTE_A4, NOTE_A4, NOTE_A4, 

    NOTE_G4, NOTE_GS4, NOTE_G4,  

    NOTE_G4, NOTE_GS4, NOTE_G4, NOTE_G4, 

    NOTE_GS4,NOTE_G4, NOTE_G4, NOTE_G4, 

    NOTE_FS4,NOTE_G4, NOTE_G4, NOTE_G4, 

    NOTE_G4, NOTE_GS4, NOTE_G4,  

    NOTE_G4, NOTE_GS4, NOTE_G4, NOTE_G4, 

    NOTE_GS4,NOTE_G4, NOTE_G4, NOTE_G4, 

    NOTE_FS4,NOTE_G4, NOTE_G4, NOTE_G4, 


 

    END 

  },

  

  {//mysong

    60, //speed

    NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,

    NOTE_F5,

    NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,

    NOTE_F5,

    NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,

    

    //NOTE_B4,NOTE_FS5,NOTE_F5,NOTE_B4,NOTE_D5,NOTE_AS5,NOTE_AS5,

    

    NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,

    NOTE_FS5,

    NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,

    NOTE_FS5,

    NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,

    

    //NOTE_B4,NOTE_FS5,NOTE_F5,NOTE_B4,NOTE_D5,NOTE_AS5,NOTE_AS5,NOTE_D5,NOTE_AS5,NOTE_AS5,

    

    NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,

    NOTE_B4,

    NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,

    NOTE_B4,

    NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,


    NOTE_F5,NOTE_FS5,NOTE_B4,

    //NOTE_B4,NOTE_FS5,NOTE_F5,NOTE_B4,NOTE_D5,NOTE_AS5,NOTE_AS5,NOTE_D5,NOTE_AS5,NOTE_AS5,NOTE_B4,

    

    END

  }


};


// note durations: 8 = quarter note, 4 = 8th note, etc.

int noteDurations[][300] = {       //duration of the notes

  {//nothing

    0,0, 

  },

  { //// Mirio underground

    0, //not read, place holder only

    12, 12, 12, 12,

    12, 12, 6,

    3,

    12, 12, 12, 12,

    12, 12, 6,

    3,

    12, 12, 12, 12,

    12, 12, 6,

    3,

    12, 12, 12, 12,

    12, 12, 6,

    6, 18, 18, 18,

    6, 6,

    6, 6,

    6, 6,

    18, 18, 18, 18, 18, 18,

    10, 10, 10,

    10, 10, 10,

    3, 3, 3

  },

  {//test

    0,

    // 1

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

        // 2

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 


    // solo 

    250, 125, 125, 1500, 

    250, 125, 125, 1500, 

    250, 125, 125, 250, 250, 2000, 

    250, 125, 125, 1500, 

    250, 125, 125, 1500, 

    250, 125, 125, 250, 250, 2500, 250, 500,

    

        // 3

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    250, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

    125, 125, 125, 125, 

  },


  { //my song

   2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,

   4,

   2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,

   6,

   2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,


   //8,8,4,8,4,8,8,


   2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,

   6,

   2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,

   8,

   2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,


  // 8,8,4,8,4,8,8,8,4,8,


   2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,

   8,

   2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,

   10,

   2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,

   

   4,6,8, 

  

  // 8,8,4,8,4,8,8,8,4,8,16,


    

  }

};


pitches.h

#define END -1

#define NO_SOUND 1

#define NOTE_B0  31

#define NOTE_C1  33

#define NOTE_CS1 35

#define NOTE_D1  37

#define NOTE_DS1 39

#define NOTE_E1  41

#define NOTE_F1  44

#define NOTE_FS1 46

#define NOTE_G1  49

#define NOTE_GS1 52

#define NOTE_A1  55

#define NOTE_AS1 58

#define NOTE_B1  62

#define NOTE_C2  65

#define NOTE_CS2 69

#define NOTE_D2  73

#define NOTE_DS2 78

#define NOTE_E2  82

#define NOTE_F2  87

#define NOTE_FS2 93

#define NOTE_G2  98

#define NOTE_GS2 104

#define NOTE_A2  110

#define NOTE_AS2 117

#define NOTE_B2  123

#define NOTE_C3  131

#define NOTE_CS3 139

#define NOTE_D3  147

#define NOTE_DS3 156

#define NOTE_E3  165

#define NOTE_F3  175

#define NOTE_FS3 185

#define NOTE_G3  196

#define NOTE_GS3 208

#define NOTE_A3  220

#define NOTE_AS3 233

#define NOTE_B3  247

#define NOTE_C4  262

#define NOTE_CS4 277

#define NOTE_D4  294

#define NOTE_DS4 311

#define NOTE_E4  330

#define NOTE_F4  349

#define NOTE_FS4 370

#define NOTE_G4  392

#define NOTE_GS4 415

#define NOTE_A4  440

#define NOTE_AS4 466

#define NOTE_B4  494

#define NOTE_C5  523

#define NOTE_CS5 554

#define NOTE_D5  587

#define NOTE_DS5 622

#define NOTE_E5  659

#define NOTE_F5  698

#define NOTE_FS5 740

#define NOTE_G5  784

#define NOTE_GS5 831

#define NOTE_A5  880

#define NOTE_AS5 932

#define NOTE_B5  988

#define NOTE_C6  1047

#define NOTE_CS6 1109

#define NOTE_D6  1175

#define NOTE_DS6 1245

#define NOTE_E6  1319

#define NOTE_F6  1397

#define NOTE_FS6 1480

#define NOTE_G6  1568

#define NOTE_GS6 1661

#define NOTE_A6  1760

#define NOTE_AS6 1865

#define NOTE_B6  1976

#define NOTE_C7  2093

#define NOTE_CS7 2217

#define NOTE_D7  2349

#define NOTE_DS7 2489

#define NOTE_E7  2637

#define NOTE_F7  2794

#define NOTE_FS7 2960

#define NOTE_G7  3136

#define NOTE_GS7 3322

#define NOTE_A7  3520

#define NOTE_AS7 3729

#define NOTE_B7  3951

#define NOTE_C8  4186

#define NOTE_CS8 4435

#define NOTE_D8  4699

#define NOTE_DS8 4978