FSR Tutorial!
7 Steps

## Step 7: BONUS! Reading FSRs without analog pins

Because FSR's are basically resistors, its possible to use them even if you don't have any analog pins on your microcontroller (or if say you want to connect more than you have analog input pins. The way we do this is by taking advantage of a basic electronic property of resistors and capacitors. It turns out that if you take a capacitor that is initially storing no voltage, and then connect it to power through a resistor, it will charge up to the power voltage slowly. The bigger the resistor, the slower it is.

This is because the capacitor acts like a bucket and the resistor is like a thin pipe. To fill a bucket up with a very thin pipe takes enough time that you can figure out how wide the pipe is by timing how long it takes to fill the bucket up halfway.

In this case, our 'bucket' is a 0.1uF ceramic capacitor. You can change the capacitor nearly any way you want but the timing values will also change. 0.1uF seems to be an OK place to start for these FSRs.

/* FSR simple testing sketch.

Connect one end of FSR to power, the other end to pin 2.
Then connect one end of a 0.1uF capacitor from pin 2 to ground

int fsrPin = 2; // the FSR and cap are connected to pin2
int ledPin = 13; // you can just use the 'built in' LED

void setup(void) {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
pinMode(ledPin, OUTPUT); // have an LED for output
}

void loop(void) {
// read the resistor using the RCtime technique

// if we got 30000 that means we 'timed out'
Serial.println("Nothing connected!");
} else {

// Do a little processing to keep the LED blinking
// The more you press, the faster it blinks!
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);
}
delay(100);
}

// Uses a digital pin to measure a resistor (like an FSR or photocell!)
// We do this by having the resistor feed current into a capacitor and
// counting how long it takes to get to Vcc/2 (for most arduinos, thats 2.5V)
int RCtime(int RCpin) {

// set the pin to an output and pull to LOW (ground)
pinMode(RCpin, OUTPUT);
digitalWrite(RCpin, LOW);

// Now set the pin to an input and...
pinMode(RCpin, INPUT);
while (digitalRead(RCpin) == LOW) { // count how long it takes to rise up to HIGH
reading++; // increment to keep track of time