Introduction: Soft Circuit Keyboard (Music)

How to make a pliable fabric “keyboard” (and accompanying glove) that plays tones and lights up when the “keys” are touched

Materials:
- Felt (8” x 6”, at least)
- LEDs (x5)
- 330 Ohm resistors (x5)
- 10K Ohm resistors (x5)
- Small piezo speaker
- Conductive thread and sewing needle
- Glove
- Sharpie or ball point pen
- Electrical wire, wire strippers, and needle nose pliers
- Arduino Uno


Step 1: Draw the Circuit

1. Copy the circuit pattern (below) onto the back of the felt using the sharpie/pen. Feel free to adjust dimensions or rearrange “wires” as desired to create different designs. (note: the mirror pattern will be on the front of the keyboard, so remember to reverse items if you wish to copy the pattern directly)

Step 2: Attach the Components


2. Attach the resistors, LEDs, and speaker to the felt. First push the leads through the felt and trim the excess wire to about 1/2”. Curl the wires into loops and bend flat against the surface of the felt.

Step 3: Sew the Circuit


3. Using the conductive thread, sew the components together as shown in the circuit diagram (replacing the wires with thread). At the end of each “wire”, sew in place a few times to create a series of loops placed close together. Be careful not to let threads or knots touch. Sew the “keys” first, then connect all the grounds and +5V with one thread each. The “switches” are created by sewing two independent “T” shapes (the glove will connect the two ends into a complete wire).

Step 4: Create the Glove


4. Sew a line of conductive thread down the tip of each finger.

Step 5: Attach the Arduino


5. Attach the circuit to the Arduino. Cut a length of wire (approximately 5” long) and strip both ends. Curl one end into a hook and push under the loops of conductive thread at the ends of each “wire”. Next, close the hook into a loop and label the wire with its pin number. Repeat this for all pins, ground, and +5V, then plug the wires into their respective pins.

Step 6: Load the Code


6. To make a basic keyboard (notes G-D, no sharps or flats) copy-paste the code below into the sketch and upload to the Arduino Uno.


int speakerPin = 9; // choose the pin for the speaker
int inputPing = 0; // choose the input pin (for a pushbutton)
int inputPina = 1;
int inputPinb = 2;
int inputPinc = 3;
int inputPind = 4;
int ledPing = 5; //choose the output pin (for an LED)
int ledPina = 6;
int ledPinb = 7;
int ledPinc = 8;
int ledPind = 10;


void setup() {
pinMode(speakerPin, OUTPUT); // declare as output
pinMode(inputPing, INPUT); // declare pushbutton as input
pinMode(inputPina, INPUT);
pinMode(inputPinb, INPUT);
pinMode(inputPinc, INPUT);
pinMode(inputPind, INPUT);
pinMode(ledPing, OUTPUT); // declare LED as output
pinMode(ledPina, OUTPUT);
pinMode(ledPinb, OUTPUT);
pinMode(ledPinc, OUTPUT);
pinMode(ledPind, OUTPUT);

}

void loop(){

if (digitalRead(inputPing) == LOW) {
tone (speakerPin, 196,100);
digitalWrite(ledPing, HIGH);

} else if (digitalRead (inputPina) == LOW){
tone (speakerPin, 220,100);
digitalWrite(ledPina, HIGH);

} else if (digitalRead (inputPinb) == LOW){
tone (speakerPin, 247,100);
digitalWrite(ledPinb, HIGH);

} else if (digitalRead (inputPinc) == LOW){
tone (speakerPin, 261,100);
digitalWrite(ledPinc, HIGH);

} else if (digitalRead (inputPind) == LOW){
tone (speakerPin, 294,100);
digitalWrite(ledPind, HIGH);

} else {
noTone (speakerPin);
digitalWrite(ledPing, LOW);
digitalWrite(ledPina, LOW);
digitalWrite(ledPinb, LOW);
digitalWrite(ledPinc, LOW);
digitalWrite(ledPind, LOW);
}
}

Step 7: Play!

7. Put on the glove and play the keyboard. The conductive thread on the gloves should line up properly to complete the “switches”. When a key is “pressed”, the corresponding LED will light up and a tone will play.

Step 8: Make It Even Cooler


8. Modifying the basic code below, make your Arduino teach you a song. An LED will light up telling you which note to play, and then turn off when you correctly play the note. The LED for the next note in the song will turn on and the process continues. Currently, it is set up to simply go through the five notes from G to D, to give the basic idea.

int speakerPin = 9;
int inputPing = 0;
int inputPina = 1;
int inputPinb = 2;
int inputPinc = 3;
int inputPind = 4;
int ledPing = 5;
int ledPina = 6;
int ledPinb = 7;
int ledPinc = 8;
int ledPind = 10;

int counter =0;

void setup() {
pinMode(speakerPin, OUTPUT);
pinMode(inputPing, INPUT);
pinMode(inputPina, INPUT);
pinMode(inputPinb, INPUT);
pinMode(inputPinc, INPUT);
pinMode(inputPind, INPUT);
pinMode(ledPing, OUTPUT);
pinMode(ledPina, OUTPUT);
pinMode(ledPinb, OUTPUT);
pinMode(ledPinc, OUTPUT);
pinMode(ledPind, OUTPUT);
}

void loop(){

if (counter == 0){
while (digitalRead(inputPing) == HIGH) {
digitalWrite(ledPing, HIGH);
noTone(speakerPin);
}
}
while (digitalRead(inputPing) == LOW) {
digitalWrite(ledPing, LOW);
tone (speakerPin, 196,100);
counter =1;
}


if (counter == 1){
while (digitalRead(inputPina) == HIGH) {
digitalWrite(ledPina, HIGH);
noTone(speakerPin);
}
}
while (digitalRead(inputPina) == LOW) {
digitalWrite(ledPina, LOW);
tone (speakerPin, 220,100);
counter =2;
}

if (counter == 2){
while (digitalRead(inputPinb) == HIGH) {
digitalWrite(ledPinb, HIGH);
noTone(speakerPin);
}
}
while (digitalRead(inputPinb) == LOW) {
digitalWrite(ledPinb, LOW);
tone (speakerPin, 247,100);
counter =3;
}

if (counter == 3){
while (digitalRead(inputPinc) == HIGH) {
digitalWrite(ledPinc, HIGH);
noTone(speakerPin);
}
}
while (digitalRead(inputPinc) == LOW) {
digitalWrite(ledPinc, LOW);
tone (speakerPin, 261,100);
counter =4;
}

if (counter == 4){
while (digitalRead(inputPind) == HIGH) {
digitalWrite(ledPind, HIGH);
noTone(speakerPin);
}
}
while (digitalRead(inputPind) == LOW) {
digitalWrite(ledPind, LOW);
tone (speakerPin, 294,100);
counter =5;
}

if (counter == 5){
counter = 0;
}