Introduction: Tissue Box Guitar - Light Strings

the idea of anything can be an instrumental music has been always in my mind so i made a wooden tissue box that i installed inside it a guitar of light strings 


Video:


equipments:

1 x Arduino Uno
1 x Adafruit Wave Shield 
1 x Servo
6 x LDR
12 x 1k Resistors
6 x LED
WIRES

Step 1: Building Box

i made this wooden tissue box 

Step 2: Wiring

we make the LDR wiring on a the top shelf of the box ... while the Led's are on the buttom shelf we place them under the LDR's directly to make the light effective on the LDR.

Ultrasonic Sensor we place it on the front side of the tissue box so it could be able to see when people comes close to it and give the servo the order to open the shelf here the servo pushes the shelf of the Led's up and they will be visible to the user !

P.S: ALL THE WIRING SHOULD BE MADE ON THE WAVE SHIELD NOT ON THE ARDUINO DIRECTLY.
i couldn't find a figure for the wave shield here  

for the sound all you have to do is to get a .Wav files of guitar strings ! or anything else you like ... and install them on the Waveshield Memory card.

Step 3: Coding

 

#include < NewPing.h >
#include < SoftwareServo.h >
#include < FatReader.h >
#include < SdReader.h >
#include < avr/pgmspace.h >
#include "WaveUtil.h"
#include "WaveHC.h"



#define TRIGGER_PIN  7 
#define ECHO_PIN     6
#define MAX_DISTANCE 500

SdReader card;  
FatVolume vol;   
FatReader root;  
FatReader f;    

WaveHC wave;     
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
SoftwareServo servo1;



unsigned int pingSpeed = 50;
unsigned long pingTimer;   



byte buttons [] = { A0, A1, A2, A3, A4, A5};

#define NUMBUTTONS sizeof(buttons)
 
int freeRam(void)
{
  extern int  __bss_end;
  extern int  *__brkval;
  int free_memory;
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end);
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval);
  }
  return free_memory;
}

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  Serial.begin(115200);

  servo1.attach(9);

   if (!card.init(true)) {
if (!card.init()) {          
   putstring_nl("Card init. failed!"); 
    sdErrorCheck();
    while(1);                        
  card.partialBlockRead(true);

  uint8_t part;
for (part = 0; part < 5; part++) {    
   if (vol.init(card, part))
      break;                           
  }
  if (part == 5) {                     
   sdErrorCheck();    
    while(1);                           
  }
 

  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(),DEC);   
 

  if (!root.openRoot(vol)) {
   putstring_nl("Can't open root dir!");

  while(1);                            
}


   }
}
}
void loop() {
 
delay(100);                    
  unsigned int uS = sonar.ping();
  Serial.print("Ping: ");
  Serial.print(uS / US_ROUNDTRIP_CM);
  Serial.println("cm");
 
   if ((uS / US_ROUNDTRIP_CM) < 50){
    servo1.write(160);
    SoftwareServo::refresh();
//    myservo1.write(90);
    }
   else {
    servo1.write(0);
    SoftwareServo::refresh();
//    myservo1.write(0);
  }

 
 

 
 
  byte i;

  static byte playing = -1;
  int sensor0 = analogRead (buttons [0]);
  int sensor1 = analogRead (buttons [1]);
  int sensor2 = analogRead (buttons [2]);
  int sensor3 = analogRead (buttons [3]);
  int sensor4 = analogRead (buttons [4]);
  int sensor5 = analogRead (buttons [5]);
if ( analogRead (buttons [0]) > 900) {
    if (playing != 0) {
      playing = 0;
      playfile("0.WAV");
    }
   
  }
//  Serial.print("LDR A1="); 
//    Serial.print(sensor1);
if ( analogRead (buttons [1]) > 900) {
    if (playing != 0) {
      playing = 0;
      playfile("1.WAV");
    }
   
  }
//  Serial.print("LDR A2="); 
//    Serial.print(sensor2);
   if ( analogRead (buttons [2]) > 900) {
    if (playing != 0) {
      playing = 0;
      playfile("2.WAV");
    }
   
  }
//    Serial.print("LDR A3="); 
//    Serial.print(sensor3);
  if ( analogRead (buttons [3]) > 150) {
    if (playing != 0) {
      playing = 0;
      playfile("3.WAV");
    }
   
  }
//  Serial.print("LDR A4="); 
//  Serial.print(sensor4);
   if ( analogRead (buttons [4]) > 150) {
    if (playing != 0) {
      playing = 0;
      playfile("4.WAV");
    }
   
  }
//  Serial.print("LDR A5="); 
//    Serial.println(sensor5);
  if ( analogRead (buttons [5]) > 150) {
    if (playing != 0) {
      playing = 0;
      playfile("5.WAV");
    }
   
  }
 
 
  if (! wave.isplaying) {
    playing = -1;
  }
}










void playcomplete(char *name) {
 
  playfile(name);
  while (wave.isplaying) {
 
  }
 
}




void playfile(char *name) {
 
  if (wave.isplaying) {
    wave.stop();
  }
 
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); Serial.print(name); return;
  }

  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); return;
  }
 

  wave.play();
}

You need to install Softwareservo Library to your arduino because waveshield and Servo uses the same Timer in arduino .. but when you use Softwareservo library it all works well.

Happy Building