Reset arduino from sketch

Is there a way to reset the whole Arduino using any instruction in the sketch? I'm working on a project that uses a key switch to cancel and forget anything the program is doing and to enter programm mode (that would be run in the setup routine). So I thought about connecting this switch to a pin setting an interrupt to monitor it and once activated reset the whole system. Is there any other workaround?

I haven't done this, but I read that you can bring the 'Reset' pin on the arduino Low (connect it to ground) and it will reset it. So connect it to a transistor, and activate the transistor with a digital pin.

Or if you're using a physical button just have the button connect it to ground.

The first question is: Why not connect the switch to the reset pin?

Other than this, you can force a reset via the internal watchdog or you can jump to address 0x0000. The last one however doesn't reset the processor to exactly the same state as a power up would, but it's good enough for most cases. If you need more details, search for Arduino and software reset. There were a few quite detailed threads on this in the old forum.


The first question is: Why not connect the switch to the reset pin?

Well, actually I was planning to activate this functionality in a specific part of the program, in other parts the switch would have other functions or no function at all.

If a soft reset is not possible, maybe setting the reset pin to LOW using a monostable 555 circuit, triggered by a digital output pin, and a transistor acting as an inverter would do the trick, don't you think? I thought about the monostable to give the resetting pulse a longer duration. The thing is, the trigger pin should be HIGH from start, or it would reset the Arduino. It looks like a risky solution.

What is wrong with using the watchdog? That's what it is there for.

I'll need a little help with the watchdog then.