programme going back to initial state after a loop sequence after every action

Hi everyone,

I have a project which involves Annikken Andee, a bluetooth shield which is connected to Arduino. I encountered a problem where my programme keeps going to the initial state after a loop sequence. Below is a part of my programme.

void setup{
UGVbutton1.setId(0); 
  UGVbutton1.setColor(LIGHT_SALMON);
  UGVbutton1.requireAck(true);
}
void loop {
if(UGVbutton1.isPressed())
 {
  UGVbutton1.ack();
  
  UGVbutton1.setColor(THEME_RED_DARK);
  UGVbutton2.setColor(LIGHT_SALMON);

  UGVSelect = 1;
 }
}

So for example if i press the button, button will turn into THEME_RED_DARK in colour. However, after about 5 seconds when the programme finished its loop, it will go back into its original colour.

One thing i want to clarify is that the main programme will not run the void setup loop after finishing the void loop. Correct me if i am wrong.

Thank you for the help.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

calai:
One thing i want to clarify is that the main programme will not run the void setup loop after finishing the void loop. Correct me if i am wrong.

setup() will only run once but an electrical or software problem can cause your Arduino to reset then it will run setup() again each time.