colorWipe was not declared error

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
GundamMaster
 
Posts: 31
Joined: Tue Feb 13, 2018 5:04 pm

colorWipe was not declared error

Post by GundamMaster »

cant get this error to go away could use some help

Code: Select all

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

#define PIN 6
#define PIN2  5


Adafruit_NeoPixel strip = Adafruit_NeoPixel(60,PIN,NEO_GRB+NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(60,PIN,NEO_GRB+NEO_KHZ800);

const int buttonPin = 4; 
int buttonState = 0;

void setup() {
  // put your setup code here, to run once:
  strip.begin();
  strip.show();
  strip2.begin(); // I added this for strip 2
  strip2.show();  // I added this for strip 2

  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
  colorWipe(strip2.Color(255,0,0),50);
  colorWipe(strip2.Color(0,255,0),50);
}
void loop() {
  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH){
    colorWipe(strip.Color(255,0,0),0);
    colorWipe(strip.Color(0,255,0),0)
  }else
    colorWipe(strip.Color(0,255,0),0);
    colorWipe(strip2.Color(0,255,0),0);
  }
}
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip2.numPixels(); i++) {
    strip2.setPixelColor(i, c); // I changed this to ‘strip 2’
    strip2.show(); // I changed this to ‘strip 2’
   delay(wait);
  }
}
Last edited by adafruit_support_bill on Tue Feb 13, 2018 5:18 pm, edited 1 time in total.
Reason: Please use [code] tags when posting code to the forums.

User avatar
adafruit_support_bill
 
Posts: 88099
Joined: Sat Feb 07, 2009 10:11 am

Re: colorWipe was not declared error

Post by adafruit_support_bill »

You have two loop() functions and the second one has unbalanced brackets. You need to have exactly one '}' for every '{'

Code: Select all

void loop() {
  colorWipe(strip2.Color(255,0,0),50);
  colorWipe(strip2.Color(0,255,0),50);
}
void loop() {
  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH){
    colorWipe(strip.Color(255,0,0),0);
    colorWipe(strip.Color(0,255,0),0)
  }else
    colorWipe(strip.Color(0,255,0),0);
    colorWipe(strip2.Color(0,255,0),0);
  }
}

User avatar
GundamMaster
 
Posts: 31
Joined: Tue Feb 13, 2018 5:04 pm

Re: colorWipe was not declared error

Post by GundamMaster »

Code: Select all

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

#define PIN 6
#define PIN2  5


Adafruit_NeoPixel strip = Adafruit_NeoPixel(60,PIN,NEO_GRB+NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(60,PIN,NEO_GRB+NEO_KHZ800);

const int buttonPin = 4; 
int buttonState = 0;

void setup() {
  // put your setup code here, to run once:
  strip.begin();
  strip.show();
  strip2.begin(); // I added this for strip 2
  strip2.show();  // I added this for strip 2

  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
  colorWipe(strip2.Color(255,0,0),50);
  colorWipe(strip2.Color(0,255,0),50);
}
void loop()   {
  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH){
    colorWipe(strip.Color(255,0,0),0);
    colorWipe(strip.Color(0,255,0),0)
  }else
    colorWipe(strip.Color(0,255,0),0);
    colorWipe(strip2.Color(0,255,0),0);
}
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip2.numPixels(); i++) {
    strip2.setPixelColor(i, c); // I changed this to ‘strip 2’
    strip2.show(); // I changed this to ‘strip 2’
   delay(wait);
  }
}

Im now getting the error of redefinition of' void look()'
Last edited by adafruit_support_bill on Tue Feb 13, 2018 5:57 pm, edited 1 time in total.
Reason: Please use [code] tags when posting code to the forums.

User avatar
adafruit_support_bill
 
Posts: 88099
Joined: Sat Feb 07, 2009 10:11 am

Re: colorWipe was not declared error

Post by adafruit_support_bill »

Please use

Code: Select all

 tags when posting code to the forums.  Click on the [code] button and paste your code between the tags.

[quote]Im now getting the error of redefinition of' void look()'[/quote]
You still have 2 loop() functions defined.  You can only have one.

[code]void loop() {
  colorWipe(strip2.Color(255,0,0),50);
  colorWipe(strip2.Color(0,255,0),50);
}
void loop()   {
  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH){
    colorWipe(strip.Color(255,0,0),0);
    colorWipe(strip.Color(0,255,0),0)
  }else
    colorWipe(strip.Color(0,255,0),0);
    colorWipe(strip2.Color(0,255,0),0);
}

User avatar
GundamMaster
 
Posts: 31
Joined: Tue Feb 13, 2018 5:04 pm

Re: colorWipe was not declared error

Post by GundamMaster »

I got ride of the two void loop and made them into one. now i have the error of expected ' ; ' before 'else'

Code: Select all

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

#define PIN 6
#define PIN2  5


Adafruit_NeoPixel strip = Adafruit_NeoPixel(60,PIN,NEO_GRB+NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(60,PIN,NEO_GRB+NEO_KHZ800);

const int buttonPin = 4; 
int buttonState = 0;

void setup() {
  // put your setup code here, to run once:
  strip.begin();
  strip.show();
  strip2.begin(); // I added this for strip 2
  strip2.show();  // I added this for strip 2

  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
  colorWipe(strip2.Color(255,0,0),50);
  colorWipe(strip2.Color(0,255,0),50);
  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH){
    colorWipe(strip.Color(255,0,0),0);
    colorWipe(strip.Color(0,255,0),0)
  else;
    colorWipe(strip.Color(0,255,0),0);
    colorWipe(strip2.Color(0,255,0),0);
  }
}
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip2.numPixels(); i++) {
    strip2.setPixelColor(i, c); // I changed this to ‘strip 2’
    strip2.show(); // I changed this to ‘strip 2’
   delay(wait);
  }
}

User avatar
adafruit_support_bill
 
Posts: 88099
Joined: Sat Feb 07, 2009 10:11 am

Re: colorWipe was not declared error

Post by adafruit_support_bill »

You can't put an 'else' in the middle of the 'if' clause. You need to close that with a '}' first.
And your 'else' has no scope. You need to define that with a '{' and a '}' as below.

Code: Select all

  if(buttonState == HIGH)
  {
    colorWipe(strip.Color(255,0,0),0);
    colorWipe(strip.Color(0,255,0),0)
  }
  else
  {
    colorWipe(strip.Color(0,255,0),0);
    colorWipe(strip2.Color(0,255,0),0);
  }

User avatar
GundamMaster
 
Posts: 31
Joined: Tue Feb 13, 2018 5:04 pm

Re: colorWipe was not declared error

Post by GundamMaster »

ok so that fixed on of the problems now im back to my first problem color wipe was not declared

Code: Select all

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

#define PIN 6
#define PIN2  5


Adafruit_NeoPixel strip = Adafruit_NeoPixel(60,PIN,NEO_GRB+NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(60,PIN,NEO_GRB+NEO_KHZ800);

const int buttonPin = 4; 
int buttonState = 0;

void setup() {
  // put your setup code here, to run once:
  strip.begin();
  strip.show();
  strip2.begin(); // I added this for strip 2
  strip2.show();  // I added this for strip 2

  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
  colorWipe(strip2.Color(255,0,0),50);
  colorWipe(strip2.Color(0,255,0),50);
  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH)
  {
    colorWipe(strip.Color(255,0,0),0);
    colorWipe(strip.Color(0,255,0),0)
}
  else
  {
    colorWipe(strip.Color(0,255,0),0);
    colorWipe(strip2.Color(0,255,0),0);
  }

void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip2.numPixels(); i++) {
    strip2.setPixelColor(i, c); // I changed this to ‘strip 2’
    strip2.show(); // I changed this to ‘strip 2’
   delay(wait);
  }
}

User avatar
caitlinsdad
 
Posts: 627
Joined: Fri Feb 24, 2012 4:23 pm

Re: colorWipe was not declared error

Post by caitlinsdad »

Please try this, I noted changes by comments in code. Good luck.

Code: Select all

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

#define PIN 6
#define PIN2  5


Adafruit_NeoPixel strip = Adafruit_NeoPixel(60,PIN,NEO_GRB+NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(60,PIN2,NEO_GRB+NEO_KHZ800);  // PIN2 Corrected

const int buttonPin = 4; 
int buttonState = 0;

void setup() {
  // put your setup code here, to run once:
  strip.begin();
  strip.show();
  strip2.begin(); // I added this for strip 2
  strip2.show();  // I added this for strip 2

  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
  colorWipe(strip2.Color(255,0,0),50);
  colorWipe(strip2.Color(0,255,0),50);
  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH)
  {
    colorWipe(strip.Color(255,0,0),0);
    colorWipe(strip.Color(0,255,0),0);  //was missing semi-colon
   }
  else
  {
    colorWipe(strip.Color(0,255,0),0);
    colorWipe(strip2.Color(0,255,0),0);
  }
} //was missing closing bracket for void loop section 
  // void colorWipe is a separate section - code segment for a function call
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip2.numPixels(); i++) {
    strip2.setPixelColor(i, c); // I changed this to ‘strip 2’
    strip2.show(); // I changed this to ‘strip 2’
   delay(wait);
  }
}

User avatar
GundamMaster
 
Posts: 31
Joined: Tue Feb 13, 2018 5:04 pm

Re: colorWipe was not declared error

Post by GundamMaster »

Code: Select all

https://photos.app.goo.gl/SLfEqHpg5FrC2Vuo2

User avatar
caitlinsdad
 
Posts: 627
Joined: Fri Feb 24, 2012 4:23 pm

Re: colorWipe was not declared error

Post by caitlinsdad »

Do the pictures mean you got it working? I couldn't tell from the pic but the neopixel strip should be powered with 5 volts. If things are still not working, try to change in the code buttonstate == LOW. You sometimes get the opposite result depending on how things get wired up and setting an internal pullup resistor on the pin.

User avatar
GundamMaster
 
Posts: 31
Joined: Tue Feb 13, 2018 5:04 pm

Re: colorWipe was not declared error

Post by GundamMaster »

I'll give that a try

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”