Arduino - running setup all the time

Hi,

I run a sketch on my Arduino UNO and realized that it runs the SETUP(), then the VOID LOOP() and while running randomly goes back to run the SETUP() again randomly but continues aterwards in the loop.

It does the same on my second Arduino UNO. Is there a configuration I don't know ?

In the serial Monitor I can see all the messages after Serial.begin(9600); in the SETUP part.

I previously uesd the Arduino UNO to load sketches on an Arduino NANO using the UNO as SPI. Can that be a reason ?

Many thanks

Marc

It sounds like the board is resetting.
How is it powered, what is connected to it ?

Please post your code that exhibits this behavior

Your Arduino may be reset. You should check the RESET pin. Make sure that it is not connected to anything.

If the reset pin was in the reset state then the Arduino would not run setup().

...R

void setup()
{ 
  pinMode(PinModus, INPUT_PULLUP); 
  pinMode(PinSet, INPUT_PULLUP); 
    
  rtc.begin();

  Modus = 0;

  R = 225 ; 
  G = 195 ;
  B = 70 ;

  pixels.begin(); 
  pixels.setBrightness( 200 )  ;
  pixels.clear() ;
 
  HellegkeetModus = 10;
 
  //TestLED();

  Serial.begin(9600); 
  LiesRTC () ;
  
  CLearPixels();
}

That's not a complete sketch.

Check you sketch for writing data outside the bounds of an array, and avoid the use of String variables.

SOLVED

I forgot to declare a pin as input. Since i corrected this, all runs fine.

Thanks for all

ArduinoLux:
I forgot to declare a pin as input.

Pins default to inputs though....