Introduction: How to Use a Force Sensitive Resistor - Arduino Tutorial
In this tutorial you will learn how to use an FSR - Force Sensitive Resistor with Arduino to fade an LED. This sensor is a variable resistor just like a photocell or flex sensor. The resistance changes by applying pressure on it.
Let's get started!
Step 1: What You Will Need
For this tutorial you will need:
- Arduino uno
- Force sensitive resistor
- 10KOhm & 220 Ohm resistors
Step 2: The Circuit
The connections are pretty easy, see the image above with the breadboard circuit schematic.
Step 3: The Code
Here's the code, embedded using Codebender!
Try downloading the Codebender plugin and clicking on the "Run on Arduino" button to program your Arduino board with this sketch. And that's it, you've programmed your Arduino with this sketch.
How it works:
- Read analog value from flex sensor
- Map analog values 0-1023 to PWM values 0-255
:: value = map(value, 0, 1023, 0, 255);
- Send pwm value to led
:: analogWrite(ledPin, value);
You can make your own modifications to the code by clicking the "Edit" button.
Step 4: Well Done!
You have successfully completed one more Arduino "How to" tutorial and you learned how to use a Force Sensitive Resistor with Arduino.
I hope you liked this, let me know in the comments.
There will be more of them, so make sure to click Follow button!