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!
What you will need
For this tutorial you will need:
- Arduino uno
- Force sensitive resistor
- 10KOhm & 220 Ohm resistors
The connections are pretty easy, see the image above with the breadboard circuit schematic.
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.
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.