This was a test using a force sensitive resistor to control the resistance of light into a series of LED's. this type of resistor causes the led's to light up depending on the amount of pressure applied. good application for touch, and floor mat sensors (although a larger FSR is advised for floor pressure)
i have posted the source code below. the flex sensor used 10k resistor grounded, an output to an I/O pin on the arduino, and a connection to positive. it will specify in the code below. enjoy!
source code:
int fsrPin = 0; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider
void setup(void) {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
}
void loop(void) {
fsrReading = analogRead(0);
Serial.print("Analog reading = ");
Serial.print(fsrReading); // the raw analog reading
// We'll have a few threshholds, qualitatively determined
if (fsrReading < 10) {
Serial.println(" - No pressure");
} else if (fsrReading < 200) {
Serial.println(" - Light touch");
} else if (fsrReading < 500) {
Serial.println(" - Light squeeze");
} else if (fsrReading < 800) {
Serial.println(" - Medium squeeze");
} else {
Serial.println(" - Big squeeze");
}
delay(1000);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment