Getting an error, can't figure out how to fix... Help!

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
epullis
 
Posts: 2
Joined: Tue Nov 06, 2018 4:08 pm

Getting an error, can't figure out how to fix... Help!

Post by epullis »

Hey there! So, I'm testing out some things for an LED project that I'm working on/teaching myself how to program a gemma via trial by error. I'm trying to set up a sparkle-type animation with multiple colors. For the most part I've been able to figure out errors and fix them, but I can't seem to figure out how to fix this one.

Here's the error:

Death_Test:39: error: 'pixels' does not name a type
Death_Test:40: error: 'pixels' does not name a type
Death_Test:41: error: expected constructor, destructor, or type conversion before '(' token
Death_Test:42: error: 'pixels' does not name a type
Death_Test:43: error: 'pixels' does not name a type
Death_Test:44: error: 'pixels' does not name a type
Death_Test:45: error: 'pixels' does not name a type
Death_Test:47: error: expected declaration before '}' token
exit status 1
'pixels' does not name a type

and here's the code i'm working with

Code: Select all

#include <Adafruit_NeoPixel.h>

#define PIN 1        
#define NUMPIXELS 20   
#define DELAY_MILLIS 30   
#define DELAY_MULT 8     
#define BRIGHT 60        
 
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

uint8_t myFavoriteColors[][3] = {(242, 90, 255),
                                 (255, 222, 30),
                                 (255, 100, 0),
                                 };

#define FAVCOLORS sizeof myFavoriteColors/3
 
void setup() {
  
  pixels.begin();
  pixels.setBrightness(BRIGHT);
  pixels.show();                
}
 
 
void loop() {
  int RColor = random(FAVCOLORS); 
}
  
  //sparkling
  int p = random(NUMPIXELS); //select a random pixel
  pixels.setPixelColor(p, RColor); 
  pixels.show();
  delay(DELAY_MILLIS * random(DELAY_MULT) ); 
  pixels.setPixelColor(p, RColor/10); 
  pixels.show();
  pixels.setPixelColor(p+1, RColor/15); 
  pixels.show();
  
}

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: Getting an error, can't figure out how to fix... Help!

Post by adafruit_support_carter »

You have an extra "}" in your code. Remove the last line here:

Code: Select all

void loop() {
  int RColor = random(FAVCOLORS);
}

User avatar
epullis
 
Posts: 2
Joined: Tue Nov 06, 2018 4:08 pm

Re: Getting an error, can't figure out how to fix... Help!

Post by epullis »

adafruit_support_carter wrote:You have an extra "}" in your code. Remove the last line here:

Code: Select all

void loop() {
  int RColor = random(FAVCOLORS);
}
whelp... not gonna lie, im almost mad at how easy that was lol thank you!

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

Return to “Arduino”