Things used in this project

Hardware components:
Ard nano
Arduino Nano R3
×1
Software apps and online services:
Ide web
Arduino IDE

Code

Happy_birthdayArduino
Don't forget to install Tone library!!
#include <Tone.h>

Tone solo;
Tone bass;
Tone rythm;

const int t = 600;  // quater note duration
const int tt = t*2;
const int t14 = round(t*1/4);
const int t24 = round(t*2/4);
const int t34 = round(t*3/4);

const int bassLedPin = 15;  // bass led signal pin (aka A1)
const int rythmLedPin = 17;  // rythm led signal pin (aka A3)
const int soloLedPin = 19;  // solo led signal pin (aka A5)

void wait(Tone t)
{
  while (t.isPlaying()) { }  
}

int bassLedState = LOW;
void switchBassLed()
{
  if (bassLedState == LOW)
    bassLedState = HIGH;
  else
    bassLedState = LOW;
  digitalWrite(bassLedPin, bassLedState);
}

int rythmLedState = LOW;
void switchRythmLed()
{
  if (rythmLedState == LOW)
    rythmLedState = HIGH;
  else
    rythmLedState = LOW;
  digitalWrite(rythmLedPin, rythmLedState);
}

int soloLedState = LOW;
void switchSoloLed()
{
  if (soloLedState == LOW)
    soloLedState = HIGH;
  else
    soloLedState = LOW;
  digitalWrite(soloLedPin, soloLedState);
}



void setup(void)
{
  pinMode(14, OUTPUT); // led ground pin (aka A0)
  pinMode(16, OUTPUT); // led ground pin (aka A2)
  pinMode(18, OUTPUT); // led ground pin (aka A4)
  pinMode(bassLedPin, OUTPUT);  // bass led signal pin
  pinMode(rythmLedPin, OUTPUT);  // rythm led signal pin
  pinMode(soloLedPin, OUTPUT);  // solo led signal pin

  pinMode(2, OUTPUT);  // solo buzzer ground pin
  pinMode(9, OUTPUT);  // rythm buzzer ground pin 

  solo.begin(6);  // solo buzzer signal pin
  bass.begin(12);  // bass buzzer signal pin
  rythm.begin(0);  // rythm buzzer signal pin

        solo.play(NOTE_D4, t34); switchSoloLed();
        wait(solo);
        solo.play(NOTE_D4, t14); switchSoloLed();
        wait(solo);
}



void loop(void)
{

bass.play(NOTE_G3, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_E4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);
bass.play(NOTE_B3, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_D4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);
bass.play(NOTE_D4, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_G4, t); switchSoloLed();
        wait(rythm); 
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);

bass.play(NOTE_D4, t); switchBassLed();
  rythm.play(NOTE_D5, t24); switchRythmLed();
        solo.play(NOTE_FS4, tt); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_FS5, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_A5, t14); switchRythmLed();
        wait(rythm);
bass.play(NOTE_FS4, t); switchBassLed();
  rythm.play(NOTE_D5, t24); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_FS5, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_A5, t14); switchRythmLed();
        wait(rythm);
bass.play(NOTE_A4, t); switchBassLed();
  rythm.play(NOTE_D5, t24); switchRythmLed();
        solo.play(NOTE_D4, t34); switchSoloLed();
        wait(rythm);        
  rythm.play(NOTE_FS5, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_A5, t14); switchRythmLed();    
        solo.play(NOTE_D4, t14); switchSoloLed();
        wait(rythm);

bass.play(NOTE_D4, t); switchBassLed();
  rythm.play(NOTE_D5, t24); switchRythmLed();
        solo.play(NOTE_E4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_FS5, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_A5, t14); switchRythmLed();
        wait(rythm);        
bass.play(NOTE_FS4, t); switchBassLed();
  rythm.play(NOTE_D5, t24); switchRythmLed();
        solo.play(NOTE_D4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_FS5, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_A5, t14); switchRythmLed();
        wait(rythm);         
bass.play(NOTE_A4, t); switchBassLed();
  rythm.play(NOTE_D5, t24); switchRythmLed();
        solo.play(NOTE_A4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_FS5, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_A5, t14); switchRythmLed();
        wait(rythm);  


bass.play(NOTE_G3, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_G4, tt); switchSoloLed();
        wait(rythm);        
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);
bass.play(NOTE_B3, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);        
bass.play(NOTE_D4, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_D4, t34); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();       
        solo.play(NOTE_D4, t14); switchSoloLed();
        wait(rythm);

bass.play(NOTE_G3, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_D5, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);        
bass.play(NOTE_B3, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_B4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);          
bass.play(NOTE_D4, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_G4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);       

bass.play(NOTE_C4, t); switchBassLed();
  rythm.play(NOTE_C5, t24); switchRythmLed();
        solo.play(NOTE_FS4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_E5, t14); switchRythmLed();  
        wait(rythm);
  rythm.play(NOTE_G5, t14); switchRythmLed();   
        wait(rythm);       
bass.play(NOTE_E4, t);  switchBassLed();
  rythm.play(NOTE_C5, t24); switchRythmLed();
        solo.play(NOTE_E4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_E5, t14); switchRythmLed();   
        wait(rythm);
  rythm.play(NOTE_G5, t14); switchRythmLed();   
        wait(rythm);          
bass.play(NOTE_G4, t); switchBassLed();
  rythm.play(NOTE_C5, t24); switchRythmLed();
        solo.play(NOTE_C5, t34); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_E5, t14); switchRythmLed();
        wait(rythm); 
  rythm.play(NOTE_G5, t14); switchRythmLed();     
        solo.play(NOTE_C5, t14); switchSoloLed();
        wait(rythm);

bass.play(NOTE_G3, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_B4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);         
bass.play(NOTE_D3, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_G4, t); switchSoloLed();
        wait(rythm);
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm); 
bass.play(NOTE_FS3, t); switchBassLed();
  rythm.play(NOTE_D5, t24); switchRythmLed();
        solo.play(NOTE_A4, t); switchSoloLed();
        wait(rythm);
        wait(rythm);
  rythm.play(NOTE_FS5, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_A5, t14); switchRythmLed();
        wait(rythm);          

bass.play(NOTE_G3, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed();
        solo.play(NOTE_G4, tt); switchSoloLed();
        wait(rythm);        
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);
bass.play(NOTE_B3, t); switchBassLed();
  rythm.play(NOTE_G4, t24); switchRythmLed(); 
        wait(rythm);
  rythm.play(NOTE_B4, t14); switchRythmLed();
        wait(rythm);
  rythm.play(NOTE_D5, t14); switchRythmLed();
        wait(rythm);      
        solo.play(NOTE_D4, t34); switchSoloLed();
        wait(solo);
        solo.play(NOTE_D4, t14); switchSoloLed();
        wait(solo);

}

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Bluetooth Controlled Car
Easy
  • 4
  • 1

Full instructions

It's a basic 4 wheel drive car which can be controlled by android phones.

Ambient 2 click board on Arduino101
Easy
  • 6
  • 1

Protip

Short article about testing Mikroelektronika Ambient 2 click board on the Arduino 101 microcontroler

Pet Feeder
Easy
  • 98
  • 2

Protip

Pet feeder is for people who live with pet together and help them to feed when they are not at home.

Grove starter kit for arduino - piezo vibration sensor
Easy
  • 159
  • 4

Protip

teaches you how to use the piezo vibration sensor in the Arduino Grove starter kit.

Pre-Bedtime Environment Analysis
Easy
  • 358
  • 6

Work in progress

Define the optimum environment for sleep by applying ML to sensor data.

ProjectsCommunitiesContestsLiveJobsBetaFree StoreBlogAdd projectSign up / Login
Respect project