is there any code that i can use to reset arduino when i need to do it?
This gets asked a lot.
Don't connect an output pin to the reset line, that won't work.
- You can use a monostable triggered by the arduino connected to the reset input.
- You can vector through the reset vector - while this will do a partial reset it won't restore the power on defaults for all internal registers.
Don't you hate when someone answers a question with another question ?
Isn't there a 'watchdog' capability which is essentially under software control ? Then you could trip the reset by changing the watchdog parameters.