0

This question already has an answer here:

I am a big noob I know that

but can this code be used to reset arduino board (instead of pressing the usual reset button on the board)

I want to reset the board as If am pressing the reset button using IR

int receiverpin = 2; // pin 1 of IR receiver to Arduino digital pin 2
#include <IRremote.h>
IRrecv irrecv(receiverpin); // create instance of irrecv
decode_results results;
void setup()
{
irrecv.enableIRIn(); // start the receiver
}
void(* resetFunc) (void) = 0; //declare reset function @ address 0

void loop()
{
 if (irrecv.decode(&results)) // have we received an IR signal?
{
if(results.value == 0x2FD847B) //if the button press equals the hex 
{
  resetFunc();
}
{
irrecv.resume(); // receive the next value
}
}
}

marked as duplicate by Nick Gammon, Community Oct 25 '15 at 16:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

Kind of, yes. That doesn't actually reset the Arduino, it just sends the program to address 0.

There are two other ways of performing the reset that do a proper full reset:

  1. Enable the watchdog timer and let it time out to reset the CPU.
  2. Connect an IO pin to the RESET pin - keep it in INPUT most of the time but set it to OUTPUT and LOW when you want to reset.

By just jumping to address 0 you aren't resetting the internal peripherals and registers to their reset state, so things like timers and such will still be running when they shouldn't be, etc. It's better by far to do a real reset instead of just jumping to 0 like that.

  • i read about both these methods and they won't allow me to reset using IR – mostafa Oct 24 '15 at 22:10
  • @mostafa And what gives you that impression? – Majenko Oct 24 '15 at 22:13
  • well the first one is a pre-set timer right?? no matter what when the timer run out the board will reset I can't see using IR here – mostafa Oct 24 '15 at 22:20
  • @mostafa You only enable the timer when it is time to do the reset. The rest of the time it's disabled so absolutely nothing happens. – Majenko Oct 24 '15 at 22:21
  • oh the second method you want me to connect an IO pin to the reset pin now I get it but won't that contain soldering ???? – mostafa Oct 24 '15 at 22:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.