Introduction: Musical Glove


Using the LilyPad Arduino, a way to create tones in the range of an octave based on thumb positioning.

SUPPLIES
Black cotton knit glove
Conductive thread
LilyPad Arduino
Sewing needle
Piezo speaker

SWITCHES
1. Place the LilyPad right side up on the backside of the glove such that pins 5-13 are near the fingers. The “LilyPad Arduino” text should be upside down when you hold the glove with the fingers up.
2. Take a long strand of conductive thread and tie it around the LilyPad’s port 13. Knot it once or twice tightly around the port so that it is firmly connected.
3. Put both ends of the knot through the needle, and sew with the thread up on the index finger. When you reach near the top of the index finger, sew the thread around on the left side to the front of the finger.
4. Make a few stitches on the finger tip to give a larger surface for the switch.
5. When you’re done, tie the thread in a knot and cut off loose ends.
6. Repeat steps 2-5 with the other switches. This is where they go:

12 Middle of index finger
11 Top of middle finger
10 Middle of middle finger
9 Top of ring finger
8 Middle of ring finger
7 Top of little finger
6 Top of palm between little and ring fingers

Be sure not to let any of the threads’ paths cross.

SPEAKER
1. Connect the ground pin to the tip of the thumb using the same method as above, going around the LilyPad. Leave a space in the stitching underneath pin 2 where the thread will be on the underside of the fabric, because you’ll need to go over it in the next step.
2. Connect pin 2 to a spot on the wrist of the glove, going over the space you left in the ground thread.
3. Using another piece of conductive thread, sew from any point on the ground thread to the wrist, making a knot about a centimeter to the left of the where you connected pin 2.
4. Push the speaker’s pins into the wrist of the glove, such that the + is connected to pin 2 and the – is connected to ground.

TIPS
- The glove’s fabric will stretch when you put it on, so sew the conductive thread with some slack.
- Make sure you only sew on one side of the glove – don’t let the thread go through to the other side because then you will sew your glove shut.
- Don’t place the LilyPad too far up on the glove; keep it closer to your wrist than your knuckles.

CODE

int speakerPin = 2;
int switchPin6 = 6;
int switchPin7 = 7;
int switchPin8 = 8;
int switchPin9 = 9;
int switchPin10 = 10;
int switchPin11 = 11;
int switchPin12 = 12;
int switchPin13 = 13;
int ledPin = 13;
int switchPins[7] = {6, 7, 8, 9, 10, 11, 12};


void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(speakerPin, OUTPUT);
  pinMode(switchPin12, INPUT);
  pinMode(switchPin13, INPUT); 
  pinMode(switchPin6, INPUT);
  pinMode(switchPin7, INPUT);
  pinMode(switchPin8, INPUT);
  pinMode(switchPin9, INPUT);
  pinMode(switchPin10, INPUT);
  pinMode(switchPin11, INPUT);
  int i = 6;
  while (i < 13) {
    digitalWrite(i, HIGH);
    i++;
  }
}

void loop() {
  digitalWrite(ledPin, HIGH);
  while (1) {
   if (digitalRead(switchPin6) == LOW) {
     digitalWrite(ledPin, LOW);
     makeNoise(6, 2093);
          digitalWrite(ledPin, HIGH);
     break;
   } 
   if (digitalRead(switchPin7) == LOW) {
     makeNoise(7, 2349);
     break;
   } 
   if (digitalRead(switchPin8) == LOW) {
     makeNoise(8, 2637);
     break;
   } 
   if (digitalRead(switchPin9) == LOW) {
     makeNoise(9, 2793);
     break;
   } 
   if (digitalRead(switchPin10) == LOW) {
     makeNoise(10, 3136);
     break;
   } 
   if (digitalRead(switchPin11) == LOW) {
     makeNoise(11, 3520);
     break;
   } 
   if (digitalRead(switchPin12) == LOW) {
     makeNoise(12, 3951);
     break;
   } 
   if (digitalRead(switchPin13) == LOW) {
     makeNoise(13, 4186);
     break;
   } 
 }

}

void makeNoise(int switchPin, int frequencyInHertz) {
          long delayAmount = (long)(1000000/frequencyInHertz);
          boolean y = true;
          while (y) {
              digitalWrite(speakerPin,HIGH);
              delayMicroseconds(delayAmount);
              digitalWrite(speakerPin,LOW);
              delayMicroseconds(delayAmount);
              y = checkforchange(switchPin);
          }
      int switchValues[7];
      int i = 0;
      while (i < 7) {
        switchValues[i] = digitalRead(switchPins[i]);
        i++;
      }
}


boolean checkforchange(int currentSensor) {
      if (digitalRead(currentSensor) == HIGH) {
        return false;
      }
      return true;
}