Software auto-reset on card insertion.

Hi,

I think this issue comes up occasionally, but the most recent post I can find on this is a couple of years old, maybe things have moved on since then?

Basically I want to force a software-reboot triggered by one of the input pins. I've got a mega arduino based project that includes both an SD and SIM card, occasionally I forget to insert one or both cards before powering up. The card holders for both cards include a 'card inserted' switch, I'd like to be able to wire this to an IO pin and make the arduino re-boot as soon as I insert a card, rather than manualy cycling the power. I've found this snippet in the forum, but there seems to be some dispute as to wether this technique is a good idea or not.

void(* resetFunc) (void) = 0; //declare reset function @ address 0
...
resetFunc(); //call reset
...

Regards

Even simpler

asm ("jmp 0");

Neither give you a full reset like the RST pin but good enough.


Rob

Neither give you a full reset like the RST pin but good enough.

...but usually good enough.

None of the hardware is reset, but setup() is called again, and loop() starts running again.