Neopixel Library error: `expected initializer before "pixels"`

EDIT: TL,DR I forgot a semicolon.



I am an Arduino noob and having difficulty figuring out the cause of a compilation error. I am able to run the neopixel example called "simple" on my Uno and I believe I am using the library very similarly in my code before but I keep getting the error pasted at the bottom of this post about expected initializer before "pixels" and highlighting the line:

Adafruit_NeoPixel pixels(NUMPIXEL, MATRIX_PIN, NEO_GRB + NEO_KHZ800);

I traced through the other lines mentioned and don't understand why this initialization doesn't appear accepted when it's almost the same as the neopixel library example. It's a global variable so it should also be in scope. I also tried using the format

Adafruit_NeoPixel pixels = Adafruit_Neopixel(NUMPIXEL, MATRIX_PIN, NEO_GRB + NEO_KHZ800);

but that didnt help

//neopixel stuff
#include <Adafruit_NeoPixel.h>
#define NUMPIXEL 16

//pins and state
const byte BUTTON1_PIN = A5;
const byte BUTTON2_PIN = A3;
const int MATRIX_PIN = 11,

Adafruit_NeoPixel pixels(NUMPIXEL, MATRIX_PIN, NEO_GRB + NEO_KHZ800);

//global var
unsigned long last_reset_time = 0;
const unsigned long ONE_DAY = 10000UL; //86400000UL;  //1 day in milliseconds

void setup() {
  pixels.begin();  
  pinMode(MATRIX_PIN, OUTPUT);
  pinMode(BUTTON1_PIN, INPUT_PULLUP);
  pinMode(BUTTON2_PIN, INPUT_PULLUP);
  //turnOn(); 

}

void loop() {

  //every 24 hours, reset LEDs to on
  if ((unsigned long) (millis() - last_reset_time) > ONE_DAY) {
    last_reset_time = millis();
    turnOn();
  }
  
  if (digitalRead(BUTTON2_PIN) == LOW){
    for (int i=NUMPIXEL; i>NUMPIXEL/2; i--){
      pixels.setPixelColor(i, pixels.Color(0, 0, 0));  
    } 
  }

  if (digitalRead(BUTTON1_PIN) == LOW){
    for (int i=1; i<=NUMPIXEL/2; i++){
      pixels.setPixelColor(i, pixels.Color(0, 0, 0));  
    } 
  }
  pixels.show();
}

Error

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

habit_keeper_v2:10:19: error: expected initializer before 'pixels'

 Adafruit_NeoPixel pixels(NUMPIXEL, MATRIX_PIN, NEO_GRB + NEO_KHZ800);

                   ^~~~~~

D:\app development\arduino\habit_keeper_v2\habit_keeper_v2.ino: In function 'void setup()':

habit_keeper_v2:17:3: error: 'pixels' was not declared in this scope

   pixels.begin();

   ^~~~~~

D:\app development\arduino\habit_keeper_v2\habit_keeper_v2.ino:17:3: note: suggested alternative: 'yield'

   pixels.begin();

   ^~~~~~

   yield

D:\app development\arduino\habit_keeper_v2\habit_keeper_v2.ino: In function 'void loop()':

habit_keeper_v2:30:5: error: 'turnOn' was not declared in this scope

     turnOn();

     ^~~~~~

habit_keeper_v2:35:7: error: 'pixels' was not declared in this scope

       pixels.setPixelColor(i, pixels.Color(0, 0, 0));

       ^~~~~~

D:\app development\arduino\habit_keeper_v2\habit_keeper_v2.ino:35:7: note: suggested alternative: 'yield'

       pixels.setPixelColor(i, pixels.Color(0, 0, 0));

       ^~~~~~

       yield

habit_keeper_v2:41:7: error: 'pixels' was not declared in this scope

       pixels.setPixelColor(i, pixels.Color(0, 0, 0));

       ^~~~~~

D:\app development\arduino\habit_keeper_v2\habit_keeper_v2.ino:41:7: note: suggested alternative: 'yield'

       pixels.setPixelColor(i, pixels.Color(0, 0, 0));

       ^~~~~~

       yield

habit_keeper_v2:44:3: error: 'pixels' was not declared in this scope

   pixels.show();

   ^~~~~~

D:\app development\arduino\habit_keeper_v2\habit_keeper_v2.ino:44:3: note: suggested alternative: 'yield'

   pixels.show();

   ^~~~~~

   yield

exit status 1

expected initializer before 'pixels'
const int MATRIX_PIN = 11,

Whoops

ugh im such an idiot. Is there a way for me to delete this thread so no one else has to waste their time? Thank you

ugh im such an idiot.

BTDTGTTS

Is there a way for me to delete this thread so no one else has to waste their time?

Let's leave it here to help anyone else that searches for the error and finds it

No.
The schadenfreude is strong.

(We've all been there)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.