Hey Hey, This is a video I made of my very first Homemade Flex Sensor in action. I intend to use this to detect the amount my neck bends while I am working. Right now though, Ive programmed an arduino to vary sound played through a speaker based on how much the fabric is bent. Here is the code for Arduino IDE (For whoever is interested). Keep in mind that I am not very skilled at programming:
/* hey hey, connect the positive side of the piezo element to pin 9 and the negative side to ground. Analog Pin 0 is hooked up to a resistor then one leg of the sensor. the other leg of the resistor goes to 5V. The other leg of the Flex Sensor goes to ground. */
const int buzzerPin = 9;//speaker is connected to pin 9 const int sensorPin = 0;//sensor is connected to A0 int raw = 0;//sets up "raw" as a variable int frequency = 0;// sets up "Frequency" as a variable
void setup() { pinMode(buzzerPin, OUTPUT);//these say speaker is an OUTPUT pinMode(sensorPin, INPUT);// and sensor is an INPUT }
void loop () { raw = analogRead(sensorPin);//reads the data from the pin frequency = raw*2;// multiplies by 2 tone(buzzerPin, frequency);//plays "frequency" value through the speaker }