Two function Reset button - long/short press I am trying to make a circuit using an ATmega328, that has a reset button that behaves like many consumer devices:


A short press just restarts the micro-controller
A long press (5 seconds?) causes the settings to be restored to default


What is the best way to achieve this behaviour? I imagine it is going to require two pins? Can it be done just using passive components?

Thanks!
It can be done with one button, one resistor, one capacitor and one GPIO pin (in addition to the RESET pin):







simulate this circuit &ndash; Schematic created using CircuitLab

Pressing the button causes a LOW pulse on the RESET pin (in the exact same way as the USB interface does).

During your startup procedure you read the GPIO pin you have chosen. If it's LOW the button is still being pressed in. If it's HIGH it has been released.

If you are using an Arduino with the normal bootloader the bootloader itself imposes a 2 second delay (which may be enough for you). Alternatively you will need to have your own delay in your program before reading the button to ensure that you have plenty of time to release the button so you don't accidentally reset your settings.