 # Force Sensing Resistor (FSR) with Arduino Tutorial

FSRs are super robust pressure sensors that are used in all kinds of industries. You will find them in electronic drums, mobile phones, handheld gaming devices and many more portable electronics. These sensors are easy to use and great for sensing pressure.

In this tutorial you will learn how an FSR works and how to use it with Arduino. I have included 3 examples with a wiring diagram and code so you can start experimenting with your sensor.

First I will show you the basic operation of the sensor. Next, we will look at using this sensor as a toggle switch. Lastly, I will show you how you can use LEDs to show the amount of pressure applied to the sensor.

If you would like to learn about other sensor, check out the articles below:

## Supplies

### Software

Makerguides.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to products on Amazon.com.

## How does an FSR work?

The resistance of an FSR depends on the pressure that is applied to the sensing area. The more pressure you apply, the lower the resistance. The resistance range is actually quite large: > 10 MΩ (no pressure) to ~ 200 Ω (max pressure). Most FSRs can sense force in the range of 100 g to 10 kg.

### Basic construction

An FSR consists of two membranes and a spacer adhesive. The conducting membranes are separated by a thin air gap when no pressure is applied. One of the membranes contains two traces running from the tail to the sensing area (the round part). These traces are woven together, but not touching. The other membrane is coated with a conducting ink. When you push on the sensor, the ink shorts the two traces together with a resistance that depends on the pressure.

### How to read an FSR?

The graph below displays the resistance vs force curve for the FSR 402 sensor. Note that the data is plotted on logarithmic scales. The response is not linear! As you can see there is a huge drop in resistance when a small amount of pressure is applied. After that, the resistance is inversely proportional to the applied force. At around 10 kg (not shown in the graph) the sensor is saturated and an increase in force yields little to no decrease in resistance.

### Voltage divider circuit

In order to measure the applied force with an Arduino, you will need to build a voltage divider circuit with the FSR and a pull-down resistor. This circuit creates a variable voltage output that can be read by the ADC (analog to digital converter) input of the microcontroller.

Selecting the right size resistor to match your sensor can be a bit tricky and depends on the force range you want to measure.

The graph above shows the Vout vs Force curves for different values of R (the pull-down resistor). A 10 kΩ resistor works well if you want to use the sensor over its entire force range (100 g to 10 kg). I like to buy these assortment boxes from Amazon so I always have a range of resistors on hand.

### Calculation example

The output voltage (Vout) that we measure with the Arduino is described by the following equation:

Vout = Vcc x R / (R + Rfsr)

So the voltage is inversely proportional to the FSR resistance. Note that the output voltage you measure is the voltage drop across the pull-down resistor, not across the FSR.

When no force is applied, the FSR resistance will be really high, take 10 MΩ as an example. I used a 10 kΩ pull-down resistor and a Vcc of 5 V for this tutorial, which results in the following output when no force is applied:

Vout = 5 V x 10 kΩ/ (10 kΩ + 10 MΩ) = 0.005 V

So almost 0 V. If you press really hard on the FSR, the resistance will go down to roughly 200 Ω. This results in the following output voltage:

Vout = 5 V x 10 kΩ/ (10 kΩ + 200 Ω) = 4.9 V

As you can see, you should be able to measure an output voltage between 0 and 4.9V depending on the amount of force you apply to the sensor.

## FSR Specifications

The technology used in FSRs is patented by Interlink Electronics which has been in operation since 1985. The most common types of FSR that you will find are the Interlink FSR 402 and 406.

This are the specifications of the round 402 sensor that I used in this tutorial.

### FSR 402 Specifications

For more information, you can check out the datasheet here. It also includes data for the other sensors of the 400 Series.

## Connecting to an FSR

The easiest way to connect to an FSR is to use a breadboard. This works great for prototyping and testing. If you need a more permanent solution, I highly recommend the Amphenol FCI Clincher Connector. You can just clamp these connectors around the silver traces of the connector and easily attach jumper or dupont cables.

### Warning

It is NOT recommended to solder directly to the exposed silver traces of the sensor. The substrate will melt during soldering and the solder joint won’t hold. Do not kink or crease the tail of the FSR if you are bending it; this can cause breaks in the printed silver traces. Interlink suggests a minimum bending radius of 2.5 mm.

## Testing an FSR

The easiest way to see if your FSR is working correctly is to connect it to a multimeter. I used alligator test leads to connect the multimeter to the exposed leads of the sensor. Put your sensor in resistance (Ω) measuring mode and you should see the resistance value change when you press on the sensor.

Because the resistance range is so big (200 kΩ to 200 Ω) it’s best to use a multimeter with autorange function. If you don’t have one of those, just play around with the range settings. 200 kΩ should enable you to see most of the range.

## Wiring – Connecting a Force Sensing Resistor (FSR) to Arduino UNO

Now that you know the sensor is working correctly, it is time to connect it to the Arduino. We will be using a breadboard and jumper wires, as this is the easiest way to prototype a circuit.

As mentioned in the introduction, you need to create a circuit with a 10 kΩ pulldown resistor.

The wiring diagram below shows you how to connect the FSR sensor to the Arduino. Note that an FSR is non-polarized, just like normal resistors. There is no positive or negative side, just connect them in the orientation you want.

Connect one of the leads of the FSR to power (5 V, but 3.3 V works just fine too) and the other lead to the analog in of the Arduino (A0). The 10 kΩ pulldown resistor gets connected between GND and A0.

## 1. FSR with Arduino example code – Analog voltage reading

Now that you have wired up the sensor, you can upload the following example code using the Arduino IDE.

This sketch will read out the sensor data from the analog input of the Arduino and display the output in the serial monitor.

As mentioned earlier, the output voltage of the sensor will be between 0 V (no pressure applied) and roughly 5 V (maximum pressure applied). The Arduino boards contain a multichannel, 10-bit analog to digital converter. This means that it will map the input voltage between 0 and 5 V into integer values between 0 and 1023. So you should see a value between 0 and 1023 in the serial monitor, depending on how hard you squeeze the sensor.

```/* Simple example code for Force Sensitive Resistor (FSR) with Arduino. More info: https://www.makerguides.com */

// Define FSR pin:
#define fsrpin A0

//Define variable to store sensor readings:
int fsrreading; //Variable to store FSR value

void setup() {
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
}

void loop() {

// Print the fsrreading in the serial monitor:
// Print the string "Analog reading = ".

// We can set some threshholds to display how much pressure is roughly applied:
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(500); //Delay 500 ms.
}```

You should see the following output in the serial monitor:

Make sure the serial monitor is also set to a baudrate of 9600.

## 2. Using a Force Sensing Resistor (FSR) as a toggle switch

In this example you will be using the FSR sensor as a toggle switch. You can use this program to control all kinds of other functions, in this case to switch on and off an LED.

You will have to add a LED with a resistor to the circuit, which is shown in the diagram below.

The negative lead of the LED (the short lead) gets connected to GND via a resistor and the positive lead to digital pin 2. The value of the resistor depends on the color LED you are using. You can use the following values as a guide:

• Blue, Green, White or UV: 68 Ω
• Red, Yellow or Yellow-Green: 150 Ω

If you don’t have any of these resistor values, try to find one that is close. You can also put multiple resistors in series, to get the correct value.

The sketch below will toggle the LED on and off when you press on the FSR. It looks at the value of the analog input pin and changes the state of the LED when the value exceeds 500. This means that a really light press won’t be detected.

This example also debounces the input and is based on the Arduino Switch tutorial.

```/* Example code to use Force Sensitive Resistor (FSR) as toggle switch to control LED. More info: https://www.makerguides.com */

// Define pins:
#define fsrpin A0
#define ledpin 2

// Define variables:
int state = HIGH; // The current state of the output pin
int previous = 0; // The previous reading from the FSR
// The follow variables are long's because the time, measured in miliseconds, will quickly become a bigger number than can be stored in an int:
long time = 0;  // The last time the output pin was toggled
long debounce = 40; // The debounce time, increase if the output flickers

void setup() {
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
// Set ledpin as output:
pinMode(ledpin, OUTPUT);
}

void loop() {

// Print the fsrreading in the serial monitor:

// If the input just went from below 500 to above 500 and we've waited long enough to ignore any noise on the circuit, toggle the output pin and remember the time:
if (fsrreading > 500 && previous < 500 && millis() - time > debounce) {
if (state == HIGH)
state = LOW;
else
state = HIGH;
time = millis();
}

digitalWrite(ledpin, state);

}```

## 3. Control multiple LEDs with an FSR as pressure sensor

The example below makes it easy to see how much pressure you apply to the FSR. The more pressure you apply, the more LEDs will turn on.

You can wire up the LEDs in the same way as before, see the wiring diagram below. The LEDs are connected to digital pin 2 to 7. The FSR is also connected in the same way as before.

Because the output voltage of the FSR is non-linear I set up a custom range for each LED to turn on. You might need to tweak this slightly for your own sensor.

```/* Arduino example code to control multiple LEDs with a Force Sensitive Resistor (FSR) as pressure sensor. More info: https://www.makerguides.com */

// Define pins:
#define fsrpin A0
#define led1 2
#define led2 3
#define led3 4
#define led4 5
#define led5 6
#define led6 7

// Define variables:

void setup() {
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
// Set LED pins as output:
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
}

void loop() {

// Print the fsrreading in the serial monitor:

// Control the LEDs:
digitalWrite(led1, HIGH);
}
else digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
}
else digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);
}
else digitalWrite(led3, LOW);
digitalWrite(led4, HIGH);
}
else digitalWrite(led4, LOW);
digitalWrite(led5, HIGH);
}
else digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
}
else digitalWrite(led6, LOW);
}```