Finger Fencing!

For my “stupid pet trick” assignment, I built a finger fencing game. It’s a really simple variation on the tone lab assignment, wherein the FSRs are sewn onto the index fingers of a pair of gloves. This idea originated with a memory I have of playing with my younger sister, pretending that our index fingers were lightsabers (complete with our own oral emulations of the sound effects). She insists that she doesn’t remember this, but I guess that doesn’t matter, so long as I’m inspired. Ideally I would have liked to use the official lightsaber sound effects for this project, but I didn’t have enough time to get anything other than a Piezo buzzer to output the sound through. Thus, I decided to mimic the setup of a fencing match instead. Since this is a proof of concept, I only used one sensor per glove, and decided that my output sound would be C4 (middle C) whenever someone hit the sensor.

I didn’t realize how sensitive FSRs were until I built this device–the usual mapping from 0 made the buzzer go off without my touching it. I found that the lightest touch I could put on the FSR was a little over 100, so I set the buzzer to go off only if the sensor reading was greater than 100. You can see how I calibrated this in the code:

[code lang="c"]int left = 0;
int right= 0;
const int buzzpin = 3;

void setup()
{
  Serial.begin(9600);
  pinMode(buzzpin, OUTPUT);
}

void loop()
{
  left = analogRead(A0);
  right = analogRead(A1);
  
  if(left > 100)
  {
    tone(buzzpin, 262, 100);
  }
  
  if(right > 100)
  {
    tone(buzzpin, 262, 100);
  }
}[/code]