I was a bit surprised by this at first, but I get excellent results by treating an FSR exactly like a tact switch. The code below illustrates this, using a debounce library that I wrote. I have the FSR connected to A0, but it is used as a digital input; any digital or analog pin can be used. I use the AVR's internal pullup so no external resistors are required.
//Counter using a Force-Sensitive Resistor (FSR) as input.
//Connect the FSR from the designated pin to ground, with no
//pullup or pull-down resistors.
//Works with this FSR https://www.sparkfun.com/products/9376
#include <Button.h> //http://github.com/JChristensen/Button
#define FSR_PIN A0 //connect fsr from this pin to ground
#define PULLUP true //use the AVR's internal pullup resistor
#define INVERT true //low level means fsr pressed
#define DEBOUNCE_TIME 50 //milliseconds
Button fsr = Button(FSR_PIN, PULLUP, INVERT, DEBOUNCE_TIME);
int counter;
void setup(void)
{
Serial.begin(9600);
}
void loop(void)
{
fsr.read();
if (fsr.wasPressed()) {
Serial.print(++counter, DEC);
Serial.println(" steps");
}
}