Arduino Force Sensor : Arduino 17th Lesson of Arduino Tutorial

In the previous post we have discussed about how to work with IR receiver using Arduino. Today we are going to talk about how to work with Force Sensor using Arduino. Let’s get started.

What is Force Sensor?

Force Sensor is a sensor which used to measure force. It has force pads and it can get force measurements. You can put weight on it and measure the force.

Pinout and Circuit diagram.

Below is the pinout of Force Sensor.


Below is the circuit diagram.

Get readings from Force Sensor.

You have to make the code like below to get readings from Force Sensor.

In this code beginning, I created an integer type variable named sensorial. It’s for storing sensor readings.

Inside the void setup, I have set the Serial Monitor’s baud rate to 9600. Then I initialized A0 pin as an input.

Then inside the void loop, I assigned sensorval analog readings of “A0” pin. Then I printed that readings in the serial monitor with a line break. Then I added 100 milliseconds delay to make a smoother running. Otherwise it’s hard to handle that type of compute for Arduino.

Get real values using Force Sensor.

You saw that Force Sensor is only giving measurements 0 to 39. But it’s not the real value. It’s the analog value. You saw the real force in the simulation. We are giving force about 0N to 10N. But out put is 0 to 39. So, you have to make 0-39 to 0-10. To do that, you have to add map function to it. You have learnt about map function before. Map function change one range in to another range. As according to above project, there is a 0-39 value range and we have to convert it to 0-10 range. To do that, you have to use map function.

In this code, we have set the serial monitor’s baud rate to 9600. Then we initialized “A0” pin as input. After that, inside the void loop, I have assigned “A0” pin’s readings into sensorval int type variable. Then I reassigned sensorval to map function. “sensorval = map(sensorval, 0, 39, 0, 10);” This is the code line. In this code, we have put the real variable inside the map function. Then we added the range what we have, it means 0 to 39 range. Then we added the range what we have to convert. It’s about 0 to 10. So, map function automatically creates and assign values. After the map function, I get output from it by putting Serial println function. It makes the serial print with line break. So, I added 100 millisecond delay for smoother running.

Would you like to be more popular? Or don’t you have much more subscribers to your YouTube channel? We have an answer, for more information, click here.

So, if you have any question regarding to this, you can comment it below. If you have any idea to improve us, please be kind enough to comment it below. We like to read your feedbacks.

Post a Comment

If you have any doubt, Let us know

Previous Post Next Post