Saturday, June 4, 2016

Force Sensor: Code and Wiring



Code:


int pressurePin = A0;
int force;
int LEDpin = 12;
void setup() {
Serial.begin(9600);
pinMode(LEDpin, OUTPUT);
}
void loop() {
  force = analogRead(pressurePin);
  Serial.println(force);
if(force > 500)
{
  digitalWrite(LEDpin, HIGH);
}
else
{
  digitalWrite(LEDpin, LOW);
}
delay(100);
}





Wiring Diagram:


16 comments:

  1. Hey Sam I want it to trigger a tone... any suggestions...

    ReplyDelete
    Replies
    1. If you still need help on this problem instead of the led you would just create a variable for the tone. Instead in the if then statement you would use your tone, hope this helps.

      Delete
  2. Hello sam, thanks for the video its crisp and clear.
    I am a beginner and i would be very grateful if you could help me out here, I want to connect 4 FSR's and 4 led's to the arduino just like you did for one.
    Can you give a code for that please.

    ReplyDelete
  3. Dude, you are my hero! Thank you for the video and the blog post!!!!

    ReplyDelete
  4. Hi, Can you send me a link of the parts you used in this project?

    ReplyDelete
  5. i plug program in and its saying there is a problem

    ReplyDelete
  6. Is there a way to set the project up with more LEDS? I want to be able to measure the different levels of force by three different colors coming on. EX:if(force > 500){ write.LEDpin,Red) BUT if(force < 500){digitalwrite. LEDpin,Yellow) BUT if(force < 250) {digitalwrite. LEDpin, Green). Also, is there a way to extend the force sensor so that its able to connect to something? (how can I correctly write the example code listed above)

    ReplyDelete
  7. Sorry i have a stupid question:
    what if i don't want to light up a led, instead i want a command to appear for instance saying "force is above bla for THIS long". so i want the micro controller to count time and measure the force applied, and give feedback to the user of how long the force is applied for.
    sorry I'm just new to the Arduino software and a bit lost.

    ReplyDelete
  8. Hey I was wondering if you could make a video showing how to make a servo react to the out puts of a pressure sensor.

    ReplyDelete
  9. Hi, how would you complete the circuit with more than 1 bulb - 4 for example?

    ReplyDelete
  10. Thank you for the video! I am in the middle of a school project and using an arduino to communicate with a thin film pressure sensor when to extend and retract a linear actuator. Your code was very helpful and I was able to effectively extend and retract the actuator when a little bit of force is applied to the sensor. However, I want to be able to increase this force so the sensor can have a larger load to it rather than me just setting my finger down and it activating. Do you have any suggestions? Should I use a resistor to increase the resistance? Thank you for your help!

    ReplyDelete
  11. i am facing difficulty as my LED wont get on when pressure is applied .
    please help asap

    ReplyDelete