Interfacing of force sensor (FSR)with an Arduino in tinkercad
In this project
we will be interfacing the Force sensor or force sensing
resistor (FSR) to the Arduino Uno. Also, we have interface
three different LEDs with Arduino.
in
this tutorial you will learn how the force sensor works and how to interface
with Arduino in tinkercad. The force is use to detect the pressure, amount of
weight applied on the sensor, there are many applications of force sensor like
it is used in electronic drum, gaming devices, industrial electronics etc.
These sensors are good for measuring pressure but not highly accurate for
measuring the weight.
Circuit Diagram:
Components Required:
§ Arduino
UNO
§ Force
sensor
§ Resistor-01
§ Red LED
§ Yellow LED
§ Blue LED
§ Connecting
wires
Connection:
The
hardware a part of this project is quite simple and easy to place together.
First of all, make the connections for the force sensor with the Arduino. The
connections for the force sensor with the Arduino given in the above circuit
diagram.
The force
sensor we used here has size 2 inch. force sensor has two pins one is connected
to the GND pin of an Arduino and another pin is connected to the digital pin of
an Arduino using the voltage divider across this pin.
Connect
the one terminal of force sensor to the GND of an Arduino.
Connect
the other terminal of FSR to resistor for creating the voltage divider.
Connect
the voltage divider output is connected to the analog input pin A0 of an
Arduino.
Connect
the red LED anode pin to digital pin 5.
Connect
the yellow LED anode pin to digital pin 4.
Connect
the blue LED anode pin to digital pin 3.
Connect
the cathode pin of all LEDs to the GND pin of an Arduino.
FSR Overview
Force
Sensor also known as Force Sensing Resistors (FSRs). These sensors
are cheaper compare to others and easy-to-interface with the microcontroller.
The kind of technology is used by FSRs has been patented
by Interlink Electronics.
There are two common types of FSR available FSR-402 and FSR-406, in market you
will find the two different size and shape FSR pictures given below.
Two kinds of FSR based on shape one is a circular and another
one is rectangular sensing area. Rectangular FSR used to sense the large area,
while small circular sensors are used sense small
area with good accuracy.
How FSR Works?
FSR is a kind of variable resistor whose value
depends upon the pressure applied to the sensor.
When there is little pressure or no
pressure, then sensor gives the high resistance output. Harder you apply the
pressure on the sensor, lower the resistance value you get, and as soon as you
remove the pressure it will get back to its original value that is high
resistance.
How to take reading of an FSR?
We
can easily read the FSR by creating the voltage divider across the FSR. For
crating voltage divider, we will connect fix value resistor (10kΩ) to one
terminal of an FSR. After that connect the fixed value resistor and the
variable FSR resistor to the analog input pin of an Arduino that is pin A0.
This is how creating voltage divider we can able to read the variable voltage
output.
Working of project:
As per the circuit diagram, the output
voltage of the FRR is connected to the analog input pin A0 of an Arduino. FSR gives the Analog output when it is pressed. The
output of the FSR is stored in variable named
forcesense. Three LEDs are connected to
the digital pin 5,4,3 respectively.
This circuit operates in three mode
When the very little force is applied on
the sensor then blue LED will turn on. is low it will turn on the green LED.
When the applied force is in between high
and low the yellow LED will turn on.
When the very high force is applied on
the sensor then red will turn on.
Code Explanation
(Block Based):
First
of all, we create a variable named forcesense to store the sensor value . For
declare the variable click on the variable block and create a variable, see the
below picture..
After
declaring the variable drag out the set block and set it to the read analog pin
A0.
Let’s use the main conditional
statement of the program that is ‘if’ block
first if statement block:
In this if block we will use the
less than “<” comparison operator.
Condition:
If the FSR value is less than 30 then pin 5
will be and pin no 4 and pin no 3 will be Low. This will make blue LED to turn
on and other two LEDs will turn off this indicates the low pressure applied.
Second if statement block:
In this, if block we will use the
three different operators two comparison operator that is less than “<”
comparison operator and “>” greater than comparison operator and last the
logical operator that is “&&” (and) operator
Condition:
If the applied force value is less than 220
and also If the applied force value is greater than 90 then pin 4 will be high
and pin no 5 and pin no 3 will be Low. This will make yellow LED turn on and
other two LEDs will turn off this indicates the medium range force is applied
on FSR.
Third if statement block:
In this, if block we will use the
three different operators two comparison operator that is less than “<”
comparison operator and “>” greater than comparison operator and last the
logical operator that is “&&” (and) operator.
Condition:
If the applied force value is less than 1023
and also If the applied force is greater than 220 then pin 3 will be high and
pin no 5 and pin no 4 will be Low. This will make the red LED turn on and the
other two LEDs will turn off this indicates the high force applied on the FSR.
[ Note:The logical operators return TRUE
or FALSE, which are defined as 1 and 0, respectively, logical operators use where
needs to make the decision based on multiple conditions.
&& is the logical and operator:
it returns a true value only when if both the conditions are true and returns a
false value when both the conditions are false]
Thanks for subscribing to my Youtube channel, here is the good news for you!! now you can join my Udemy course for FREE. fill the below form and you will receive the free Udemy coupon code in your mail. click on below link.
https://docs.google.com/forms/d/e/1FAIpQLSfY7sanjTlF6qgfFOo5mY68J8izOklnZ_f5-fJ3ecuQFsImmw/viewform?usp=sf_link
forcesense = 0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
}
void loop()
{
forcesense = analogRead(A0);
Serial.println(forcesense);
if (forcesense < 30) {
digitalWrite(5, HIGH);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
}
if (forcesense > 90 && forcesense
< 220) {
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
digitalWrite(3, LOW);
}
if (forcesense > 220 && forcesense
< 1023) {
digitalWrite(5, LOW);
digitalWrite(4, LOW);
digitalWrite(3, HIGH);
}
delay(10); // Delay a little bit to improve
simulation performance
}
This blog is really helpful for me as I was looking for high performance Submersible Level Transducers at affordable rates.
ReplyDeleteNoshok gauges distributors