0

I am working on a project where I would like to press on a pressure sensor (0-1024) once and turn on the LED and turn off by itself after 6 seconds. I am quite new to arduino and I can't seem to understand how to code this with using a pressure sensor as a switch rather than an actual switch. Any ideas?

  • When it is allowed that the Arduino does nothing during the delay, you can use the delay() function. Using millis() is a lot better, but that requires a specific way to use it. The Blink Without Delay ( arduino.cc/en/Tutorial/BlinkWithoutDelay ) is a start to learn how to use millis(). Is the pressure sensor a FSR ? Is it a school project ? Can you show your sketch ? – Jot Apr 24 '17 at 8:40
1

Sensors which give a range of outputs need to have their outputs processed using a technique called hysteresis. That is, normally, the turn on threshold is higher then the turn off threshold.

For example, the thermostat in your home uses hysteresis when controlling your HVAC system. Otherwise your thermostat would constantly be turning on and off your HVAC system likely causing an early failure.

Here is a stackexchange Arduino question about hysteresis.

0

If you're having a problem implementing the system in software, there is a hardware approach to do it. The phenomenon is called monostable multivibrator. Monostable mode retains its output for a certain time interval before coming back to previous state. You can use a simple RC circuit configuration to implement this functionality along with Arduino setup. Just interface FSR in voltage divider format, read the voltage and switch another GPIO interfaced with RC circuit configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.