You are on page 1of 6

Instructables

How to Use a Force Sensitive Resistor - Arduino Tutorial


Introduction: How to Use a Force Sensitive Resistor - Arduino Tutorial
About: Arduino Tutorials by Codebender.cc Team More About codebender_cc »

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!

Add TipAsk QuestionCommentDownload

Step 1: What You Will Need


For this tutorial you will need:

Arduino uno

Breadboard

Force sensitive resistor

LED
10KOhm & 220 Ohm resistors

Add TipAsk QuestionCommentDownload

Step 2: The Circuit

The connections are pretty easy, see the image above with the breadboard circuit schematic.

Add TipAsk QuestionCommentDownload

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
:: 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.

Add TipAsk QuestionCommentDownload

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.

You might also like