Yang
Yang

Reputation: 141

How to reset arduino Mega 2560 code automatically?

I am working on the temperature project using arduino to collect temperature. But sometimes arduino hang there so I have to unplug cord and plug it back in to restart the arduino. I do not when it is going to hang up again. So I decide to do some research on the internet but no luck for that. Here is the article I read about resetting arduino code with watchdog timer library.(unfortunately, it only work for arduino uno) If someone has any idea how to reset arduino mega 2560 code. Please help !!

Upvotes: 0

Views: 2870

Answers (1)

Meet Desai
Meet Desai

Reputation: 173

You can reset the Arduino using the following syntax: First declare a function

    void(* resetFunc) (void) = 0;//declare reset function at address 0

Then call the function wherever you want to reset the controller.

    resetFunc();

Upvotes: 1

Related Questions