Hardware circuit to Trigger Board Reset through software - In essence, push the reset button through a software trigger
Ok, I don't know if this is the right section to post this in but I thought I would share this since I couldn't find an answer when I was searching for this so hopefully the next person needing to "push the reset button through software" will be able to find and use this.
I needed a way to reset the board through software for my project without causing issues with uploading new software to the chip. I had found one solution online but you had to disconnect the trigger pin every time you wanted to upload a new sketch which was not a viable solution to me. So I build the following circuit:http://i1040.photobucket.com/albums/b409/Initialforce/HardwareReset_zpsfa99e2a4.jpg
Capacitor is charged by Pin 15 (on my Mega). The first transistor is triggered by Pin 14 which in turn causes the capacitor to latch the first transistor open until discharged which in turn triggers the 2nd transistor to open and ground the reset pin. When the board resets itself it automatically writes all digital Pins to LOW and the circuit closes after the capacitor is discharged. I ran my Mega through 30 some test runs in 10 second intervals and it's working great. Holds the reset pin LOW just long enough to trigger the reset. Have not tested this on any other board but in theory, if it doesn't work on another board because it does not hold it open long enough you could always bump up the capacitor value.
Code wise here is what you need (and yes I am fully aware this is not actually a HARD Reset but that's what I called it in my sketch):
Declare you pins:
const byte HardResetPowerPin = 15;
const byte HardResetTriggerPin = 14;
Write the following in void Setup:
// Set HardResetPins to OUTPUT
// Set HardResetTriggerPin LOW (just in case)
// Power Reset Capacitor
Then at any point you want to trigger the Reset:
I have read quite a few horror stories about people locking their board with some software reset loop, unable to upload a new sketch to fix it because it is constantly resetting itself, so I personally prefer this method over any others I have been able to find online because if you accidentally get it stuck in a reset loop, simple disconnect the ground from transistor #2 or disconnect the reset pin on the board.
Hope this is of help to someone out there.