Arduino Nano - Force Sensor

This tutorial instructs you how to use Arduino Nano with the force sensor. In detail, we will learn:

As a typical application, You can put your things on the force sensor, and then if the Arduino Nano detects a change in force, it means someone has grabbed your belongings.

Hardware Preparation

1×Arduino Nano
1×USB A to Mini-B USB cable
1×Force Sensor
1×10 kΩ resistor
1×Breadboard
1×Jumper Wires
1×(Optional) 9V Power Adapter for Arduino Nano
1×(Recommended) Screw Terminal Adapter for Arduino Nano

Or you can buy the following sensor kit:

1×DIYables Sensor Kit 30 types, 69 units
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you. We appreciate your support.

Overview of Force Sensor

Force sensor pinout

The force sensor is referred to as a force sensing resistor, force sensitive resistor, or simply FSR. It is essentially a resistor that changes its resistive value in response to the amount of pressure applied. The force sensor has the following characteristics:

  • It is inexpensive and straightforward to use.
  • It is adept at recognizing physical pressure and squeezing.
  • It is not suitable for determining the number of pounds of weight it is bearing.

The force sensor is used in a variety of portable electronics, such as electronic drums, mobile phones, and handheld gaming devices.

The Force Sensor Pinout

A force sensor has two pins which are symmetric and do not need to be distinguished as it is a type of resistor.

How It Works

The force sensor is essentially a resistor that varies its resistance depending on the amount of pressure applied. As the pressure increases, the resistance between the two terminals decreases.

Wiring Diagram

The wiring diagram between Arduino Nano and Force

This image is created using Fritzing. Click to enlarge image

How To Program For Force Sensor

Arduino Nano's pins A0 to A7 can be used as analog inputs. These analog input pins convert the voltage (ranging from 0v to VCC) into integer values (ranging from 0 to 1023), referred to as ADC value or analog value. We can connect the force sensor to an analog input pins and use analogRead() function to read the analog value.

Arduino Nano Code

/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-force-sensor */ #define FORCE_SENSOR_PIN A7 // The FSR and 10K pulldown are connected to A7 void setup() { Serial.begin(9600); } void loop() { int analogReading = analogRead(FORCE_SENSOR_PIN); Serial.print("Force sensor reading = "); Serial.print(analogReading); // print the raw analog reading if (analogReading < 10) // from 0 to 9 Serial.println(" -> no pressure"); else if (analogReading < 200) // from 10 to 199 Serial.println(" -> light touch"); else if (analogReading < 500) // from 200 to 499 Serial.println(" -> light squeeze"); else if (analogReading < 800) // from 500 to 799 Serial.println(" -> medium squeeze"); else // from 800 to 1023 Serial.println(" -> big squeeze"); delay(1000); }

Detailed Instructions

  • Copy the code and open it in the Arduino IDE.
  • Click the Upload button to transfer the code to the Arduino Nano.
  • Press the force sensor.
  • Check the results in the Serial Monitor.
COM6
Send
Force sensor reading = 0 -> no pressure Force sensor reading = 0 -> no pressure Force sensor reading = 132 -> light touch Force sensor reading = 147 -> light touch Force sensor reading = 394 -> light squeeze Force sensor reading = 421 -> light squeeze Force sensor reading = 607 -> medium squeeze Force sensor reading = 791 -> medium squeeze Force sensor reading = 921 -> big squeeze Force sensor reading = 987 -> big squeeze Force sensor reading = 0 -> no pressure Force sensor reading = 0 -> no pressure
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Video Tutorial

Learn More