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?
2 Answers
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.
- 7,513
- 2
- 13
- 19
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.
- 141
- 5