I have a FSR sensor, where I need to ensure that it has a pressing value of at least 250 in 7 seconds. The values are not important, but needs to be above 250 in 7 seconds in order to run an other function.

The only thing I got so far is this.

FSRreading = AnalogRead(FSR);

if(FSRreading>250) {


So this only checks once and execute the other_function. How can I ensure that it has been pressed for 7 seconds?

  • It can be solved with millis, start with the blink-without-delay example: arduino.cc/en/Tutorial/BlinkWithoutDelay – Jot Dec 6 at 10:04
  • What was preventing you from going further? Have you googled about doing timed things on Arduino? You already have code for checking once. So now you need to check repeatedly for the time of 7 seconds. Put it in while loop, which exits after a specific time (using the millis() function, a bit like in the BlinkWithoutDelay example of the Arduino IDE). – chrisl Dec 6 at 10:05
  • what do you want to do if it was not pressed for 7 seconds? – Juraj Dec 6 at 13:38

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.