Force Sensing Resistor (FSR) Arduino Simple Tutorial

by RonFrtek in Circuits > Arduino

2055 Views, 3 Favorites, 0 Comments

Force Sensing Resistor (FSR) Arduino Simple Tutorial

Force Sensing Resistor (FSR) Arduino Simple Tutorial

In this tutorial we will learn how to detect the force applied to the Force Sensing Resistor (FSR) and display it on the OLED Display + we will set the limits with a green and a red LED.

Watch a demonstration video.

What You Will Need

arduino.jpg
force-sensor.jpg
oled.jpg
LED5MM.png
download.jpg
11026-Jumper_Wires_Standard_7in._M_M_-_30_AWG__30_Pack_-01.jpg
Half-Sized_Breadboard_-_Oblique_-_600__61198.1507056554.1280.1280.png
VisuinoAdvrtisementM5Stack3.jpg
  1. Arduino UNO (or any other Arduino)
  2. Force sensor
  3. OLED display
  4. RED & GREEN LED
  5. 1K ohm resistor
  6. Jumper wires
  7. Breadboard
  8. Visuino program: Download Visuino

Start Visuino, and Select the Arduino UNO Board Type

FFR2XFGK1UXJLG8.LARGE.jpg
F8LR4HQK1UXJLG7.LARGE.jpg

To start programming the Arduino, you will need to have the Arduino IDE installed from here: https://www.arduino.cc/.

Please be aware that there are some critical bugs in Arduino IDE 1.6.6. Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work! If you have not done follow the steps in this Instructable to setup the Arduino IDE to program Arduino UNO! The Visuino: https://www.visuino.eu also needs to be installed. Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

In Visuino Add Components

2019-12-10_23-35-44.jpg
2019-12-10_23-35-22.jpg

  1. Add "SSD1306/SH1106 OLED Display (I2C)" component
  2. Add 2x "Compare Analog Value" component

In Visuino Set Components

2019-12-10_23-38-51.jpg
2019-12-10_23-39-09.jpg
2019-12-10_23-45-03.jpg
2019-12-10_23-44-48.jpg

  1. Double click on the "DisplayOLED1" component and in the "Elements" dialog window drag "Text Field" to the left
  2. select on the right "Text Field1" and in the properties window set size:3 and Y:40
  3. Select "CompareValue1" component and in the properties window set Compare Type: ctSmallerOrEqual
    and value: 0.1

    "CompareValue1" is used to trigger the Green LED, it means whenever the input value is smaller or equal to 0.1 trigger the LED
  4. Select "CompareValue2" component and in the properties window set Compare Type: ctBigger

and value: 0.1
"CompareValue2" is used to trigger the Red LED, it means whenever the input value is bigger than 0.1 trigger the red LED

In Visuino Connect Components

FORCESENSOR.png
2019-12-11_0-22-51.jpg
  1. Connect Arduino Analog Out pin [0] to "CompareValue1" component pin [In]
  2. Connect Arduino Analog Out pin [0] to "CompareValue2" component pin [In]
  3. Connect Arduino Analog Out pin [0] to "DisplayOLED1>Text Field1" component pin [In]
  4. Connect "DisplayOLED1" component to Arduino I2C pin [In]
  5. Connect "CompareValue1" component pin [Out] to Arduino digital pin [8]
  6. Connect "CompareValue2" component pin [Out] to Arduino digital pin [7]

Generate, Compile, and Upload the Arduino Code

F0P14MMK1UXJMQ8.LARGE.jpg
FCG1WWZK1UXJMQ7.LARGE.jpg

In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE

In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

Play

If you power the Arduino UNO module, and press the force sensor sensor you should see a changing number on the OLED display and a green LED should light but when you hit the limit the red LED should shine.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it here and open it in Visuino: https://www.visuino.eu

Circuit

2019-12-11_0-03-23.jpg

  1. Connect Arduino Positive pin [5V] to OLED pin [VCC] and Force sensor pin [1]
  2. Connect Arduino Negative pin [GND] to OLED pin [GND]
  3. Connect OLED Display pin [SDA] to Arduino pin [SDA]
  4. Connect OLED Display pin [SCL] to Arduino pin [SCL]
  5. Connect Force sensor pin [2] to Arduino Analog pin [0]
  6. Connect Force sensor pin [2] to 1K ohm resistor
  7. Connect other side of the resistor to Arduino Negative pin[GND]
  8. Connect Green LED negative pin to Arduino pin [GND]
  9. Connect Green LED Positive pin to Arduino Digital pin [8]
  10. Connect Red LED negative pin to Arduino pin [GND]
  11. Connect Red LED Positive pin to Arduino Digital pin [7]