My loop wasn't working


#1

A few days ago I made a loop that started in the middle rather than the beginning. This is what the loop code looks like;

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}
Timer timer;
LED led;
Animation animate;
void button_press(void) {
timer.pause(1000);
animate.breathe_single_color(ORANGE);
timer.pause(800);
animate.breathe_single_color(PURPLE);
timer.pause(800);
animate.breathe_single_color(PERIWINKLE);
timer.pause(800);
animate.breathe_single_color(ROSE);
timer.pause(800);
animate.breathe_single_color(OCEAN);
timer.pause(800);
animate.breathe_single_color(SKY);
timer.pause(800);
animate.breathe_single_color(GREEN);
timer.pause(800);
animate.breathe_single_color(CYAN);
timer.pause(800);
animate.breathe_single_color(RED);
timer.pause(800);
animate.breathe_single_color(BLUE);
timer.pause(800);
animate.breathe_single_color(WHITE);
timer.pause(800);
animate.breathe_single_color(MAGENTA);
timer.pause(800);
animate.breathe_single_color(GOLD);
timer.pause(800);
animate.breathe_single_color(YELLOW);
timer.pause(800);
animate.jewelbots_logo();
timer.pause(1000);

}

Does anybody have any suggestions?
This is what it looks like


#2

The only thing I’m noticing is that your code isn’t within the loop() function; it is outside of it. Your whole loop function is:

void loop() {
// put your main code here, to run repeatedly:

}

So remove that closing curly brace:

void loop() {
// put your main code here, to run repeatedly:

Timer timer;
LED led;
Animation animate;
void button_press(void) {
timer.pause(1000);
animate.breathe_single_color(ORANGE);
timer.pause(800);
animate.breathe_single_color(PURPLE);
timer.pause(800);
animate.breathe_single_color(PERIWINKLE);
timer.pause(800);
animate.breathe_single_color(ROSE);
timer.pause(800);
animate.breathe_single_color(OCEAN);
timer.pause(800);
animate.breathe_single_color(SKY);
timer.pause(800);
animate.breathe_single_color(GREEN);
timer.pause(800);
animate.breathe_single_color(CYAN);
timer.pause(800);
animate.breathe_single_color(RED);
timer.pause(800);
animate.breathe_single_color(BLUE);
timer.pause(800);
animate.breathe_single_color(WHITE);
timer.pause(800);
animate.breathe_single_color(MAGENTA);
timer.pause(800);
animate.breathe_single_color(GOLD);
timer.pause(800);
animate.breathe_single_color(YELLOW);
timer.pause(800);
animate.jewelbots_logo();
timer.pause(1000);
}


#3

When in doubt, make a backup of your code and make a new project - paste a few lines of code at a time, test, and then continue adding once you ensure each step works! :slight_smile: