Step 5: Simple code for analog FSR measurements

This code doesn't do any calculations, it just prints out what it interprets as the amount of pressure in a qualitative manner. For most projects, this is pretty much all that's needed!

/* FSR simple testing sketch.

Connect one end of FSR to power, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground

For more information see www.ladyada.net/learn/sensors/fsr.html */

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

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");
why you are dividing fsrconductance by 80 and in else part by 30. <br> <br>(if (fsrConductance &lt;= 1000) { <br>fsrForce = fsrConductance / 80; <br>Serial.print(&quot;Force in Newtons: &quot;); <br>Serial.println(fsrForce); <br>} else { <br>fsrForce = fsrConductance - 1000; <br>fsrForce /= 30; <br>Serial.print(&quot;Force in Newtons: &quot;); <br>Serial.println(fsrForce); <br> <br>kindly Explain this part of the code..
very good tutorial about how to interface a force sensor. also, I add this tutorial in my <a href="http://www.intorobotics.com/force-sensors-reviewed-and-programming-tutorials/" rel="nofollow">article about force sensors</a>
These work very well. I was able to hook them up to an Arduino with a simple voltage divider circuit (as suggested by the FSR integration guide), but I did not have to use an amplifier.<br> <br> I wrote a simple script to send the pressure data via serial from the Arduino, and then used it in a Panda3D Python application.<br> <br> They would probably not work for extremely accurate measurements, but I am able to control the pressure in the application with my fingertips quite well for my purposes.<br> <br> Cioara from <a href="http://www.45bet.com/betclic" rel="nofollow">Betclic</a>
Curious if once calibrated at zero, 1/3,2/3 and full scale, do these devices hold as far as remaining consistent? <br> With low linearity, what was the application these were designed for?
A very interesting Instructable. Thanks
Very interesting!

About This Instructable


73 favorites


Bio: All-original DIY electronics kits - Adafruit Industries is a New York City based company that sells kits and parts for original, open source hardware electronics projects ... More »
More by adafruit: Adaruit Resistor Helper Adafruit Photo Tutorial Logger Shield: Datalogging for Arduino
Add instructable to: