How to Use a Force Sensitive Resistor - Arduino Tutorial
by codebender_cc in Circuits > Arduino
66989 Views, 226 Favorites, 0 Comments
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!
What You Will Need
For this tutorial you will need:
- Arduino uno
- Breadboard
- Force sensitive resistor
- LED
- 10KOhm & 220 Ohm resistors
The Circuit
The connections are pretty easy, see the image above with the breadboard circuit schematic.
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
:: value=analogRead(sensorPin);
- 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.
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!