Can an Arduino be made non-retriggerable?

Hello everyone,

I want an Arduino to:

  1. Wait for a button press to begin rotating a paddle.
  2. On the press rotate the paddle one full turn (360 degrees), which then stops.
  3. Ignore any button presses for a set amount of time after the initial press (I can determine that time through experimentation, but for sake of example let's say 2.5 minutes).
  4. Then return to (1) above and wait for a key press to begin the process again.

(In other words, the device should make the paddle rotate once, then prevent the paddle from moving again for a predetermined amount of time. Then it should once again allow a user to press a key and begin the process all over again - i.e. non-retriggerable.)

Is this feasible for an Arduino? If so, any recommendations as to hardware and/or programming would be much appreciated. So far I'm planning on an Uno with motor shield, and bi-polar stepper, whose specific torque I will figure out later.

Thanks very much.

Very much straightforward, perfectly feasible.

Look at FSM (finite state machines) in the playground and the blink without delay example.


You can use external interrupts. Within the Interrupt Service Routine, you need to have two blocks, one which responds to the key press and a dummy block which does nothing for 2.5 minutes. You can make effective use of millis() function here. Make sure you debounce the switch when using it to trigger external interrupts.

Thanks for your help, sreedevk and holmes4. sreedevk, could you expand on your answer? This will be the first time I've ever worked with an Arduino, so I'm pretty ignorant about it.

If what was specified in the OP is the full requirement, you could do this in a very crude way using delay. In loop, use digitalread to check for a button press. When you detect one, start the paddle motor. Then delay for however long experiment tells you it takes to turn through 360 degrees. Turn the paddle motor off. Delay for 2.5 minutes.

Use of delay like this is usually frowned on. If you want to do other things during the 2.5 minute delay or the paddle turn (emergency stop perhaps), you can't. So as suggested, using millis as in the blink without delay example is preferred. Often, your requirements will evolve and having locked yourself into the use of delay may mean a rewrite. But for quick and dirty, delay will get you going.

Interrupts are not needed for this and just introduce needless complexity.

Look at the StateChangeDetection example sketch to see how to detect when the button has been pressed.

In your case you could just write some blocking code which carries out the sequence of actions you want, using delay() for the timed parts. The code would look remarkably like your pseudocode:

Wait for a button press. Start the motor turning. Wait until the motor has reached the required position. Stop the motor. Delay for 2.5 minutes.

It's not elegant, and if you had any plans for your sketch to do anything else in parallel with this behaviour in future then you'd be better using a non-blocking approach, but this would certainly get you working and only take a couple of dozen lines of code.