Sunday, April 1, 2007

First Prototype

Yesterday we made our first prototype, pictured here. It features two .2" fsrs hot-glued to the inside of the mouth-guard. We were able to hook it up to a MIDI synth and play two different notes by pressing on the fsrs (holding the mouth-guard, not having it in my mouth). Unfortunately, when I put it in my mouth, we didn't get the same results. It seemed like one note would stay on no matter what, and one note only played some of the times we wanted it to. We're not sure if we damaged an fsr in all the twisting of wires or if I damaged one with saliva when the saran wrap accidentally slipped. Working with FSRs is SO frustrating!! They are incredibly delicate and break really easily. We've definitely broken at least two and haven't yet determined if the two that are attached to the mouthpiece are still working. So before Thursday, our goal is to test the FSRs on the mouthpiece to see if they're still working, and if not, replace them. We ordered 15 more FSRs over the weekend that will hopefully arrive before then.

The Code
#define fsr 0
#define fsr2 1

// Middle C (MIDI note value 60) is the lowest note we'll play:
#define middleC 60

// Variables:

int AnalogValue = 0;
int AnalogValue2 = 0; // value from the analog input
int lastNotePlayed = 0; // note turned on when you press the switch
int note=0;

void setup()

{
// set the states of the I/O pins:
pinMode(fsr, INPUT);
pinMode(fsr2, INPUT);
// Set MIDI baud rate:
Serial.begin(31250);
}


void loop()
{
AnalogValue = analogRead(0);
AnalogValue2 = analogRead(1);

//Serial.println(AnalogValue);

if (AnalogValue >100)
{
note = 60;
noteOn(0x90, note, 0x40);
// save the note we played, so we can turn it off:
lastNotePlayed = note;
}

else if (AnalogValue2 >100)
{
note = 70;
noteOn(0x90, note, 0x40);
// save the note we played, so we can turn it off:
lastNotePlayed = note;
}

}

void noteOn(char cmd, char data1, char data2)

{
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}

0 comments: