I am trying to perform a loop and then stop the loop when the last line of code in the if statement is printed to screen saving on CPU cycles.I want to start a while loop and then kill the loop after it is complete, but not breaking out of the loop so I can re-initiate the loop once again by pressing a GPIO button B1.My end goal is to have the RGB LED cycle and not continue to loop once it is complete.Setup: RPi 3, RGB LED, button and breadboard.#include <stdio.h>#include <string.h>#include <sys/types.h>#include <bcm2835.h>#define LED_RED RPI_GPIO_P1_12 //GPIO 18#define LED_GRN RPI_GPIO_P1_16 //GPIO 23#define LED_BLU RPI_GPIO_P1_18 //GPIO 24#define B1 RPI_GPIO_P1_22 //GPIO 25int main(int argc, char **argv){    if (!bcm2835_init()) return 1;    bcm2835_gpio_fsel(LED_RED, BCM2835_GPIO_FSEL_OUTP);    bcm2835_gpio_fsel(LED_GRN, BCM2835_GPIO_FSEL_OUTP);    bcm2835_gpio_fsel(LED_BLU, BCM2835_GPIO_FSEL_OUTP);    bcm2835_gpio_fsel(B1, BCM2835_GPIO_FSEL_INPT);    bcm2835_gpio_set_pud(B1, BCM2835_GPIO_PUD_UP);    bcm2835_gpio_len(B1);    unsigned int delay = 1000;    while (1){        printf(Light cycle machine\n);        if(bcm2835_gpio_eds(B1)!=0){            printf(Button Pressed!!!\n);            printf(\n);            bcm2835_gpio_set(LED_RED);            printf(Red LED on!!!\n);            bcm2835_delay(delay);            bcm2835_gpio_clr(LED_RED);            printf(Red LED off!!!\n);            bcm2835_gpio_set(LED_GRN);            printf(Green LED on!!!\n);            bcm2835_delay(delay);            bcm2835_gpio_clr(LED_GRN);            printf(Green LED off!!!\n);            bcm2835_gpio_set(LED_BLU);            printf(Blue LED on!!!\n);            bcm2835_delay(delay);            bcm2835_gpio_clr(LED_BLU);            printf(Blue LED off!!!\n);            delay(delay);            bcm2835_gpio_set_eds(B1);            printf(\n);            printf(System Idle\n);            }        else{            delay(delay);            //printf(Done!\n);            }        if (bcm2835_gpio_eds(B1)!=1)            {                   }        else{            }}    return 0;}
Pausing a loop with a Raspberry Pi 3
beginner;c;raspberry pi