Description
In this lab, I got an LED to light and dim depending on the pressure of the FSR. My inspiration was actually not for LED light, but with a heating element. So theoretically, we could wire the FSR to be in your sock such that when you pressed down on a particular spot (say right under your big toe), it could turn on a heating element. Then when you're in a cold place, your toes, extremities that lose heat FAST, could be heated at your wish. I didn't have a heating element, so an LED compensated.
Components
Arduino board
Green LED
Breadboard
One 220-ohm resistor
One 10-ohm resistor
1 FSR
Arduino Code
/*
* Resistive Sensor Input
* Takes the input from a resistive sensor, e.g., FSR or photocell
* Dims the LED accordingly, and sends the value (0-255) to the serial port
*/
int sensorPin = 0; // select the input pin for the sensor
int ledPin = 11; // select the output pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(sensorPin); // read the value from the sensor, 0-1023
analogWrite(ledPin, val/4); // analogWrite (dimming the LED) can be between 0-255
Serial.println(val/4); // writing the value to the PC via serial connection
delay(50); //
}
Mechanical Part
My sister gave me a mushroom candy tin earlier this semester. The lid is neither screw-open nor pop-cap-off, but more like a suction cap. As such, there can be different levels of pressure between the cap and jar. This can be used for the FSR, achieving hardest pressure, no pressure, and soft to semi-hard pressure in between.
LED not lighted
LED lighted
Mushroom