Lab 6: Piezo and FSR

Nicholas's picture

Artifact

I designed a very simple toy by combining the FSR and the piezo speaker. I folded a tiger mask (designed by Jun Maekawa) and slotted the FSR into the nose. The piezo speaker is hidden in folds in the back of the model. When the user presses the nose, the speaker creates a low sound. The code is a modified version of the theremin example code.

Materials

  • 1 15cm square piece of paper
  • 1 FSR
  • 1 Piezo speaker
  • 1 Arduino
  • 2 10K resistors

Code

 

/* Tiger mask with FSR and piezo sensor
 * --------
 *
 * Nicholas Kong
 * Lab 6: Piezo
 * October 4, 2011
 *
 * Modified Theremin code by:
 *
 * Created 24 October 2006
 * copyleft 2006 Tod E. Kurt <tod@todbot.com
 * http://todbot.com/
 */
 
int potPin = 0;    // select the input pin for the FSR
int speakerPin = 7;
 
int val = 0;
 
void setup() {
  pinMode(speakerPin, OUTPUT); 
  Serial.begin(9600);
}
 
void loop() {
  digitalWrite(speakerPin, LOW);
  
  val = analogRead(potPin);    // read value from the sensor
  if(val > 5) {
    Serial.println(val);
  }
  val = val/3;                 // process the value a little
   
  // Only make noise if the force sensor is depressed.
  if(val > 1) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(val);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(val);
  }
}
 
Tiger mask with circuit
Force sensor slotted into tiger mask nose.
0
Your rating: None