Error calling a function

Hi everyone.

I'm having trouble calling a function I have written for a small piece of code. I've written functions for other project before and never had a problem getting them to compile. I've been staring at this for quite a while now and I'm sure I'm just not seeing the wood for the trees so could really use with a fresh pair of eyes.

The complier error is...

'colorWipe' was not declared in this scope

neopixel_experiment.ino: In function 'void loop()':
neopixel_experiment:91: error: 'colorWipe' was not declared in this scope

The code I am trying to compile is this (the function and it's call are near the bottom).

Many thanks :slight_smile:

#include <Adafruit_NeoPixel.h>

#define PIN 0 // Output pin for Neopixels

#define PotIn 1 /* Input from pot for brightness control, analog 1
is pin #2 on Trinket */

#define button 3
                
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

int potValue = 0;
int but1;
int color = 0; /* 0 = red, 1 = green, 2 = blue, 3 = r+g, 4 = r+b, 5 = g+b,
6 = r+b+g */
int newPress = 0;

void setup() {
  pinMode (button, INPUT);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  for (int i=0; i<strip.numPixels(); i++) {
    if (color == 0) {
      strip.setPixelColor(i, 255, 0, 0); // set all pixels to red
    }
    else if (color == 1) {
      strip.setPixelColor(i, 0, 255, 0); // set all pixels to green
    }
    else if (color == 2) {
      strip.setPixelColor(i, 0, 0, 255); // set all pixels to blue
    }
    else if (color == 3) {
      strip.setPixelColor(i, 255, 255, 0); // set all pixels to red+green (y)
    }
    else if (color == 4) {
      strip.setPixelColor(i, 255, 0, 255); // set all pixels to red+blue (m)
    }
    else if (color == 5) {
      strip.setPixelColor(i, 0, 255, 255); // set all pixels to green+blue (c)
    }
    else {
      strip.setPixelColor(i, 255, 255, 255); // set all pixels to white
    }
  }
  potValue = map(analogRead(PotIn), 0, 1023, 0, 255); /* read value from pot 
and use map function to change 10-bit value to 8-bit */
  strip.setBrightness(potValue); // sets 8-bit brightness value
  strip.show(); // updates pixels
  if (digitalRead(button) == LOW) { // pin 3 tied high so low means pressed
    but1 = 1;
  } // initially sets button state to high and waits for debounce
  else {
    newPress = 0;
    but1 = 0; // finger off of button so reset values to 0
  }
  delay(50);
  if (but1 == 1 && newPress == 0 && digitalRead(button) == LOW) {
    /*checks if button had been pressed before the delay and is still pressed
    therefore is debounced AND that the previous time through the loop the
    button was not pressed hence the newPress == 0 */
    newPress = 1; /* registers a confirmed button press and also prevents the above
    if statement running again until button released as this value will remain 1
    until the button is released */
    if (color < 6) {
      ++color; // increments value of color if less than 6
    }
    else { // should only run if value of color is 6
      color = 0; // resets color to red
    }
    colorWipe(); 
  }
}

void colorWipe(){
  
  int pause = 100;
  for (int j=0; j<strip.numPixels(); j++) {
    if (color == 0) {
      strip.setPixelColor(j, 255, 0, 0); // set all pixels to red
      strip.show(); // updates single pixel just changed
      delay(pause); // controls speed of wipe
    }
    else if (color == 1) {
      strip.setPixelColor(j, 0, 255, 0); // set all pixels to green
      strip.show(); // updates single pixel just changed
      delay(pause); // controls speed of wipe
    }
    else if (color == 2) {
      strip.setPixelColor(j, 0, 0, 255); // set all pixels to blue
      strip.show(); // updates single pixel just changed
      delay(pause); // controls speed of wipe
    }
    else if (color == 3) {
      strip.setPixelColor(j, 255, 255, 0); // set all pixels to red+green (y)
      strip.show(); // updates single pixel just changed
      delay(pause); // controls speed of wipe
    }
    else if (color == 4) {
      strip.setPixelColor(j, 255, 0, 255); // set all pixels to red+blue (m)
      strip.show(); // updates single pixel just changed
      delay(pause); // controls speed of wipe
    }
    else if (color == 5) {
      strip.setPixelColor(j, 0, 255, 255); // set all pixels to green+blue (c)
      strip.show(); // updates single pixel just changed
      delay(pause); // controls speed of wipe
    }
    else {
      strip.setPixelColor(j, 255, 255, 255); // set all pixels to white
      strip.show(); // updates single pixel just changed
      delay(pause); // controls speed of wipe
    }
  }
}
int newPress = 0;

void colorWipe();

void setup()

allows your code to compile. Something bizarre that the adafruit library is doing, I guess.

Change this:

#define PotIn 1 /* Input from pot for brightness control, analog 1
is pin #2 on Trinket */

to this:

#define PotIn 1 /* Input from pot for brightness control, analog 1 is pin #2 on Trinket */

Ok so that was a little weird but it has worked perfectly! Many thanks!!