Project tutorial
Music... Differently

Music... Differently © CC BY

I want to built some interractive Things for education sensibilisation. We go in school for talking about technology, with our machine !

  • 3,279 views
  • 3 comments
  • 15 respects

Components and supplies

About this project

I. Why The Project ? 

This project has been imagine in an educational Way, I would built some interactive machines for helping kids to understand New technology.


The Theme is Music, because it's universal and it's nice for kids.

I built two machines who plays music in a different way !


The aim and a demonstration of the project can be fin in this video : 

This project is in two part and can be extend one day ! 


1. An No-Contact Piano

2.An Automatics drum !



II. No-Contact Piano : 


This System is an interactive piano wich you will never touch anything ! 

Just shake your hand at the top of the device and music will be play ! 


More high is your hand, more Sharp is the sound.

More down is your hand, more Low is the sound  ! 


HOW IT'S WORK ?????


Hum... Intresting schematic.

So, the "capteur Ultra son" wich Means Ultrasonic Sensor will give us a distance. 

And we will convert this distance in a frequency !! 


Ready ?

Lets Play : 


a. Electronics Part : 


- Put a wire between GND of the HC - SR04 sensor and the GND of the Arduino

- Put a wire between VCC of the HC - SR04 sensor and the 5V of the Arduino

- Put a wire between TRIG and the I/O N°12 of the ARDUINO

- Put a wire between ECHO and the I/O N°13 of the ARDUINO

------------------Ultrasonic Part Done--------------------

Find a jack Plug Somwhere ^^ 

- Connect the + of the jack at the I/O N°11 of the ARDUINO

- Connect the - of the jack at the GND of the ARDUINO

If your plug is not with screw... use a soldering iron to help your wire to be connected.


b. Software Part : 


Then you can deploy the code below : 


// Name the pin as led.

#define speaker 11


// Set the Snt end Pin & Receive Pin.

int trig = 12;

int echo = 13;

long cmm;


void setup()

{

pinMode(trig, OUTPUT);

digitalWrite(trig, LOW);

pinMode(echo, INPUT);

Serial.begin(9600);

}


void loop()

{

// Set a timer.

long start = millis();


cmm=What_Range();


if(cmm>10 && cmm<70)

{

tone(speaker, 440*cmm/30);

delay(100);

}

else

{

delay(10);

}


Serial.println(cmm);

noTone(speaker); // arbitrary delay to limit data to serial port

}


int What_Range()

{

int cm;

digitalWrite(trig, HIGH);

delayMicroseconds(10);

digitalWrite(trig, LOW);

cm = pulseIn(echo, HIGH) / 58;

return(cm);

}


c. Test Part

Now you can plug the jack to your speaker (can be the Hi-Fi speaker of your bedroom !!)


Put your hand in front of the sensor and... Have fun !! 


#DavidGuetta #FrenchSong #D.I.Y

III. Automatics Drum :


Now lets moove on to the second music instrument : The amazing Automatic Drum.



This Drum has be made for lazy poeple or for poeple who just can't drum correctly... (Like me :-(   )


You have in your hand a remote with two buttons, if you push the left buttons, the left stick hit the drum and if you push the right button : EVRYTHING FALL DOWN IN AN EXPLOSION... hum... no in fact the right stick hit the drum ^^ 


Lets explain this with a schem : 


So for this module you will need 

-Two Servomotor

-Two Potentiometer

-Three Buttons

-An Arduino Nano


a. Electronic part : 


- Connect two Servomotors to the PIN 9 and 6 of your arduino.

- Connect two led to the PIN 7 and 8 of your arduino [Help for Debug] 

- Connect two potentiometer to the PIN A0 and A1. [control Position and speed]

- Connect tree buttons to the PIN 12, 2 , 4.


Some help to connect your button and led : 


Ok now we are ready to deploy our programm : 


b. Sofware

You can conect the usb Wire, open arduino and deploy this programm : 

#include <Servo.h>


Servo myservo1;  // create servo object to control a servo

Servo myservo2; 


int pos = 0;

int pos1 = 0;

int potpin0 = 0;  // analog pin used to connect the potentiometer

int potpin1 = 1;


int angleMaxGauche;

int angleMinGauche;

int angleMaxDroite;

int angleMinDroite;

int temp;


int boutonIni = 12;

int bouton0 = 2;

int bouton1 = 4;

int led1 = 8;

  

void setup() {

  myservo1.attach(9); 

  myservo2.attach(6);

  // attaches the servo on pin 9 to the servo object

    pinMode(boutonIni, INPUT);

    pinMode(bouton0, INPUT);

    pinMode(bouton1, INPUT);

    pinMode(led1, OUTPUT);

    Serial.begin(9600);

    

 //   digitalWrite(led1, HIGH);

    initialisation(); //on entre les positions min et max des servo

    Serial.println(angleMaxGauche);

     Serial.println(angleMinGauche);

      Serial.println(angleMaxDroite);

       Serial.println(angleMinDroite);

    

}


void loop() {

  

temp=pota(); //lit la valeur de la vitesse de la baguette (potard droit)


if(digitalRead(bouton0)==LOW){

 baguetteGauche(temp);

}  else if(digitalRead(bouton1)==LOW) {

  baguetteDroite(temp);

}  else if(digitalRead(bouton0)==LOW && digitalRead(bouton1)==LOW){

  baguetteGauche(temp);

  baguetteDroite(temp);


  }

 


}






void baguetteGauche(int temp) {

  digitalWrite(8,HIGH);

 for (pos = angleMinGauche; pos <= angleMaxGauche; pos += 5) { 

    myservo1.write(pos);              

         delay(temp);                

  }

    for (pos = angleMaxGauche; pos >= angleMinGauche; pos -= 5) { 

    myservo1.write(pos);              

    delay(temp);                      

  }

  digitalWrite(8,LOW);

  }

  

  

  

  

  void baguetteDroite(int temp) {

     digitalWrite(7,HIGH);

 for (pos1 = angleMaxDroite; pos1 <= angleMinDroite; pos1 += 5) { 

    myservo2.write(pos1);              

         delay(temp);                

  }

    for (pos1 = angleMinGauche; pos1 >= angleMaxGauche; pos1 -= 5) { 

    myservo2.write(pos1);              

    delay(temp);                      

  }

   digitalWrite(7,LOW);

  }

  

  

  

  int pota(){

 

  int poti = analogRead(A1);

  

   poti = map(poti, 0, 1023, 5, 50);

   

   return poti;

   

  }

  

  

  


void initialisation(){

 int val1 = analogRead(A0); 

// Serial.read(boutonIni);

 

 

 Serial.println("Initialiser angle de frappe du moteur gauche");

 while(digitalRead(boutonIni)==HIGH){

 val1 = analogRead(A0); 

  val1 = map(val1, 0, 1023, 0, 180);

 myservo1.write(val1);

 delay(10);

 


 }


delay(1000);


angleMaxGauche = val1;

 

 


  int val2 = analogRead(A0);

 

  Serial.println("Initialiser angle de repos du moteur gauche"); 

 while(digitalRead(boutonIni)==HIGH){

    val2 = analogRead(A0); 

 val2 = map(val2, 0, 1023, 0, 180);

 myservo1.write(val2);

 delay(10);



 }

 

 delay(1000);


 angleMinGauche = val2;

 

 

 

 

 int val3 = analogRead(A0); 

  Serial.println("Initialiser angle de frappe du moteur droite");

 while(digitalRead(boutonIni)==HIGH){

     val3 = analogRead(A0); 

 val3 = map(val3, 0, 1023, 0, 180);

 myservo2.write(val3);

 delay(10);


 

 }

 delay(1000);


 angleMaxDroite = val3;

 


 

  int val4 = analogRead(A0);

  Serial.println("Initialiser angle de repos du moteur droite"); 

 while(digitalRead(boutonIni)==HIGH){

     val4 = analogRead(A0); 

 val4 = map(val4, 0, 1023, 0, 180);

 myservo2.write(val4);

 delay(10);


 }

 delay(1000);


angleMinDroite = val4;

 

}


well done ! 


c. Use it 


Sothe initialisation is started automatically : 


Start with the left motor : 

--Set the maximum position with the potentiometer A0, validate by pushing the button on pin 12.

--Set the minimum position with the potentiometer A0, validate by pushing the button on pin 12

Now the left motor : 

--Set the maximum position with the potentiometer A0, validate by pushing the button on pin 12.

--Set the minimum position with the potentiometer A0, validate by pushing the button on pin 12


And it's over !! 

So now you can play by pushing button 2 and 4 ! 


It's too slow ? No problem, the potentiometer A0 is here to control the speed of the motor.


Thank to Conard and Maximiliens Saunier For helping Me in this project ! 

Have Fun 

Code

Code Arduino For The DrumArduino
Just deploy it on your arduino nano
#include <Servo.h>

Servo myservo1;  // create servo object to control a servo
Servo myservo2; 

int pos = 0;
int pos1 = 0;
int potpin0 = 0;  // analog pin used to connect the potentiometer
int potpin1 = 1;

int angleMaxGauche;
int angleMinGauche;
int angleMaxDroite;
int angleMinDroite;
int temp;

int boutonIni = 12;
int bouton0 = 2;
int bouton1 = 4;
int led1 = 8;
  
void setup() {
  myservo1.attach(9); 
  myservo2.attach(6);
  // attaches the servo on pin 9 to the servo object
    pinMode(boutonIni, INPUT);
    pinMode(bouton0, INPUT);
    pinMode(bouton1, INPUT);
    pinMode(led1, OUTPUT);
    Serial.begin(9600);
    
 //   digitalWrite(led1, HIGH);
    initialisation(); //on entre les positions min et max des servo
    Serial.println(angleMaxGauche);
     Serial.println(angleMinGauche);
      Serial.println(angleMaxDroite);
       Serial.println(angleMinDroite);
    
}

void loop() {
  
temp=pota(); //lit la valeur de la vitesse de la baguette (potard droit)

if(digitalRead(bouton0)==LOW){
 baguetteGauche(temp);
}  else if(digitalRead(bouton1)==LOW) {
  baguetteDroite(temp);
}  else if(digitalRead(bouton0)==LOW && digitalRead(bouton1)==LOW){
  baguetteGauche(temp);
  baguetteDroite(temp);

  }
 

}





void baguetteGauche(int temp) {
  digitalWrite(8,HIGH);
 for (pos = angleMinGauche; pos <= angleMaxGauche; pos += 5) { 
    myservo1.write(pos);              
         delay(temp);                
  }
    for (pos = angleMaxGauche; pos >= angleMinGauche; pos -= 5) { 
    myservo1.write(pos);              
    delay(temp);                      
  }
  digitalWrite(8,LOW);
  }
  
  
  
  
  void baguetteDroite(int temp) {
     digitalWrite(7,HIGH);
 for (pos1 = angleMaxDroite; pos1 <= angleMinDroite; pos1 += 5) { 
    myservo2.write(pos1);              
         delay(temp);                
  }
    for (pos1 = angleMinGauche; pos1 >= angleMaxGauche; pos1 -= 5) { 
    myservo2.write(pos1);              
    delay(temp);                      
  }
   digitalWrite(7,LOW);
  }
  
  
  
  int pota(){
 
  int poti = analogRead(A1);
  
   poti = map(poti, 0, 1023, 5, 50);
   
   return poti;
   
  }
  
  
  

void initialisation(){
 int val1 = analogRead(A0); 
// Serial.read(boutonIni);
 
 
 Serial.println("Initialiser angle de frappe du moteur gauche");
 while(digitalRead(boutonIni)==HIGH){
 val1 = analogRead(A0); 
  val1 = map(val1, 0, 1023, 0, 180);
 myservo1.write(val1);
 delay(10);
 

 }

delay(1000);

angleMaxGauche = val1;
 
 

  int val2 = analogRead(A0);
 
  Serial.println("Initialiser angle de repos du moteur gauche"); 
 while(digitalRead(boutonIni)==HIGH){
    val2 = analogRead(A0); 
 val2 = map(val2, 0, 1023, 0, 180);
 myservo1.write(val2);
 delay(10);


 }
 
 delay(1000);

 angleMinGauche = val2;
 
 
 
 
 int val3 = analogRead(A0); 
  Serial.println("Initialiser angle de frappe du moteur droite");
 while(digitalRead(boutonIni)==HIGH){
     val3 = analogRead(A0); 
 val3 = map(val3, 0, 1023, 0, 180);
 myservo2.write(val3);
 delay(10);

 
 }
 delay(1000);

 angleMaxDroite = val3;
 

 
  int val4 = analogRead(A0);
  Serial.println("Initialiser angle de repos du moteur droite"); 
 while(digitalRead(boutonIni)==HIGH){
     val4 = analogRead(A0); 
 val4 = map(val4, 0, 1023, 0, 180);
 myservo2.write(val4);
 delay(10);

 }
 delay(1000);

angleMinDroite = val4;
 
}
  
 
  
  
  
  
  
  
  
  
  
Code For the PianoArduino
Deploy this code on your arduino Leonardo or UNO
// Name the pin as led.
#define speaker 11

// Set the Snt end Pin & Receive Pin.
int trig = 12;
int echo = 13;
long cmm;

void setup()
{
pinMode(trig, OUTPUT);
digitalWrite(trig, LOW);
pinMode(echo, INPUT);
Serial.begin(9600);
}

void loop()
{
// Set a timer.
long start = millis();

cmm=What_Range();

if(cmm>10 && cmm<70)
{
tone(speaker, 440*cmm/30);
delay(100);
}
else
{
delay(10);
}

Serial.println(cmm);
noTone(speaker); // arbitrary delay to limit data to serial port
}

int What_Range()
{
int cm;
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
cm = pulseIn(echo, HIGH) / 58;
return(cm);
}

Schematics

Piano Schem
Schema%20 %20piano%20sans%20touche
Drum Schem
Schema%20 %20caisse%20claire%20automatique

Comments

Similar projects you might like

Music Reactive LED Strip

Project showcase by buzzandy

  • 23,857 views
  • 51 comments
  • 59 respects

Pinball Sounds and Music

Project tutorial by Bob Blomquist

  • 6,097 views
  • 3 comments
  • 18 respects

Infinity Mirror VU Meter Music Equalizer

Project showcase by TheTNR

  • 5,434 views
  • 4 comments
  • 27 respects

EL Tape Music Visualiser

Project tutorial by Paul Scott

  • 4,147 views
  • 12 comments
  • 13 respects

Control Music Volume and Ledbar Using Slider of 1Sheeld

Project tutorial by ahmed ismail

  • 1,576 views
  • 2 comments
  • 12 respects

Electronic Music

Project showcase by Glauber Santiago

  • 883 views
  • 1 comment
  • 0 respects
Add projectSign up / Login