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
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 UNO (or any other Arduino)
- Force sensor
- OLED display
- RED & GREEN LED
- 1K ohm resistor
- Jumper wires
- Breadboard
- Visuino program: Download Visuino
Start Visuino, and Select the Arduino UNO Board Type
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
- Add "SSD1306/SH1106 OLED Display (I2C)" component
- Add 2x "Compare Analog Value" component
In Visuino Set Components
- Double click on the "DisplayOLED1" component and in the "Elements" dialog window drag "Text Field" to the left
- select on the right "Text Field1" and in the properties window set size:3 and Y:40
- 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 - 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
- Connect Arduino Analog Out pin [0] to "CompareValue1" component pin [In]
- Connect Arduino Analog Out pin [0] to "CompareValue2" component pin [In]
- Connect Arduino Analog Out pin [0] to "DisplayOLED1>Text Field1" component pin [In]
- Connect "DisplayOLED1" component to Arduino I2C pin [In]
- Connect "CompareValue1" component pin [Out] to Arduino digital pin [8]
- Connect "CompareValue2" component pin [Out] to Arduino digital pin [7]
Generate, Compile, and Upload the Arduino Code
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
- Connect Arduino Positive pin [5V] to OLED pin [VCC] and Force sensor pin [1]
- Connect Arduino Negative pin [GND] to OLED pin [GND]
- Connect OLED Display pin [SDA] to Arduino pin [SDA]
- Connect OLED Display pin [SCL] to Arduino pin [SCL]
- Connect Force sensor pin [2] to Arduino Analog pin [0]
- Connect Force sensor pin [2] to 1K ohm resistor
- Connect other side of the resistor to Arduino Negative pin[GND]
- Connect Green LED negative pin to Arduino pin [GND]
- Connect Green LED Positive pin to Arduino Digital pin [8]
- Connect Red LED negative pin to Arduino pin [GND]
- Connect Red LED Positive pin to Arduino Digital pin [7]