Is it possible to reset an Arduino (i.e., to reboot it) from code (i.e from the sketch itself)? I know that is possible with a special circuit but is there a chance to make it just with code?
Below is my code and the comment //reset is where I want to force a reset.
#include <TrueRandom.h>
int i;
int randSeed;
long randNumber;
void setup(){
Serial.begin(9600);
Serial.println("20 pseudo Zufallszahlen:");
for (i=1;i<=20;i++) Serial.print(random(10));
Serial.println();
Serial.println();
//randomSeed(TrueRandom.random());
randSeed = analogRead (A0);
randomSeed(randSeed);
Serial.print("Der 'seed' Wert: ");
Serial.println(randSeed);
Serial.println();
Serial.println("20 Zufallszahlen mit analogem 'seed' Wert:");
for (i=1;i<=20;i++) Serial.print(random(10));
Serial.println();
Serial.println("---------------------------");
Serial.println();
delay(500);
//reset
}
void loop() {
}
I want to reset the micro-controller at the end of the setup function to show the effect of random numbers with and without a seed.
resetFunc()not reset the stack? So calling it repeatedly would overflow the stack. – Kevin Smyth Aug 19 '16 at 17:150. A pointer to the function to be called should be used insteadvoid(* resetFunc) (void) = &setup;(in this case setup should be called to begin again, or even main if it makes sense) I just had the case with stm32 where it begins later in the memory. – Dardan Iljazi Dec 26 '19 at 13:12