Reset arduino

Hello, I want to do 2 things:

1st) I want to reset arduino when I send "reset" word through serial! Can this happen?
2nd) I want to reset arduino when I reset the power! Can this happen?

Thank you!

You get 2nd) for free. The first is best done by creating your own reset function that puts things in the state you want them. That function can be called by setup() as well as your code when it detects "reset"

KeithRB:
You get 2nd) for free. The first is best done by creating your own reset function that puts things in the state you want them. That function can be called by setup() as well as your code when it detects "reset"

When I reset the power, it does not reset the program! I must press reset button.

How I make a reset function? Is there a guide?

If the serial process is running, then the board must have been reset. So trying to fix it that way won't work, because if it really hasn't been reset, there will be no serial communications.

Resetting the Arduino from code is really not a good idea. There is no way to re-invoke the bootloader from running code. Resetting the Arduino from code is almost always an attempt to ignore a problem with the code that really should be fixed.

So, what problem are you trying to ignore?

Which is why I said to simply run a function that resets the user state, and does not literally reset the arduino.

What hardware are you using?

aarg:
What hardware are you using?

Arduino MEGA 2560

alex5678:
Arduino MEGA 2560

Load the Blink Without Delay sketch from the IDE. Now try power cyling it. Tell us what happens.

PaulS:
Resetting the Arduino from code is really not a good idea. There is no way to re-invoke the bootloader from running code. Resetting the Arduino from code is almost always an attempt to ignore a problem with the code that really should be fixed.

So, what problem are you trying to ignore?

I just want to use command-controlled reset! No problem at all.

I just want to use command-controlled reset!

Why? That is the real question.

Pressing the reset button from code is not possible. Any other "reset" method does not do all the same things that pressing the reset button does. Whether that matters, or not, depends on what you REALLY want a program-initiated reset to do.

You could enable the watchdog and then forget to kick it.
But really it is best to ask yourself why you want to do that.

I just want to use command-controlled reset! No problem at all.

I see you didn't want to play the "solve the actual problem" game. Okay. Be that way.

If you really want to reset the board in software, you can connect an output pin to the reset pin. As soon as you configure it as output, the board will reset. There is the watchdog, but this is simpler for a noob.

Please, just don't tell anybody that I suggested it. :slight_smile:

Please, just don't tell anybody that I suggested it. :slight_smile:

Never. But I did bookmark this thread. 8) (For bribery purposes, later)

Or watch my YouTube video, 4 ways to reset your Arduino.

OK, I am using the word 'reset' in the widest possible sense. But you asked, I replied :o

URL in the signature of this post.

Hello, I found what was wrong. The supply cable was not stable-connected! Now it resets just fine when I reset power!