Cellphone type power button

Look for button libraries; there are several that allow you to read a short vs. a long press. Combine this with a finite state machine and you've got the basics. Then implement in such a way that you don't use delay() as it will mess up responsiveness of the device to user input.

As to getting started: I'd say start by reading a button and distinguishing between long and short press; once you got that down, experiment with making a simple state machine that cycles through a couple of predefined states. Then combine the button and the state machine. Finally write the code for the relevant outputs (leds, motors etc) for each particular state.

1 Like