Overriding Loop

How do you program an overriding loop, so that the code loops when you it reaches the end? I wrote a code, but it doesn’t loop.
Thanks

 #include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
int threshold = 500; //Change This
int volume;

void setup() {

Serial.begin(9600);

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}


void loop() {
  // Some example procedures showing how to display to the pixels:

 volume = analogRead(A0);
 
  if(volume>=threshold){
  Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
 
  
  colorWipe(strip.Color(25, 150, 75), 1); // Neuron Transmitter
  colorWipe(strip.Color(0, 0, 0), 1);
  }
}
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

We have no idea how to solve your problem because we can't see it. Please post your code using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpreted by the forum code as italics or funny emoticons.

Unless the sketch is too large, it's better if you post your code, rather than attach it. When it's attached, we have to download it, create a folder then open your code in our IDE. Or perhaps open it in WordPad, which isn't very good for looking at code. And afterwards, the folder remains unless we navigate to the "Temp" folder and manually remove it. It's much easier to just view the code in your post.

If you simply wish to run your program once, put your code in setup() and leave loop() empty. But I'm guessing.

Like this :

[code]Your source code here[/code]

How do you program an overriding loop, so that the code loops when you it reaches the end?

Like this :

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

}

We have a code that we want to loop, but it doesn’t with this code.

sound_and_light.ino (1.13 KB)

 #include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
int threshold = 500; //Change This
int volume;

void setup() {

Serial.begin(9600);

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}




void loop() {
  // Some example procedures showing how to display to the pixels:

 volume = analogRead(A0);
 
  if(volume>=threshold){
  Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
 
  
  colorWipe(strip.Color(25, 150, 75), 1); // Neuron Transmitter
  colorWipe(strip.Color(0, 0, 0), 1);
  }
}
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
  if(volume>=threshold){
  Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

Lose the " Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);"

Thanks!