Skip to main content
added 28 characters in body; edited title
Source Link
Michel Keijzers
  • 13k
  • 7
  • 42
  • 59

how How to declare a pointer for arduino neopixels library so I can set it up in the setup function with dynamic variables?

I am using neopixelNeoPixel strips, and I want to be able to declare a pointer to them, but not initialize them until the setupsetup function (because they will initialize with certain variables only made available in setupsetup).

For simpler data types, I am just doing:

int totalNumColors = 4; //number of colors user can cycle through`
uint32_t* colorArray = new uint32_t[totalNumColors];
void setup() {
  for (int i=0;i<totalNumColors;i++){
    colorArray[i] = totalColorArray[i];
  }
}

How do I do this for neopixelNeoPixel strip intializers? I tried:

Adafruit_NeoPixel* pixels = new Adafruit_Neopixel;

Adafruit_NeoPixel* pixels = new Adafruit_Neopixel;`

but I get the error:

expected type-specifier before 'adafruit neopixel'

how to declare a pointer for arduino neopixels library so I can set it up in the setup function with dynamic variables

I am using neopixel strips, and I want to be able to declare a pointer to them, but not initialize them until the setup function (because they will initialize with certain variables only made available in setup.

For simpler data types, I am just doing:

int totalNumColors = 4; //number of colors user can cycle through`
uint32_t* colorArray = new uint32_t[totalNumColors];
void setup() {
  for (int i=0;i<totalNumColors;i++){
    colorArray[i] = totalColorArray[i];
  }
}

How do I do this for neopixel strip intializers? I tried:

Adafruit_NeoPixel* pixels = new Adafruit_Neopixel;

but I get the error:

expected type-specifier before 'adafruit neopixel'

How to declare a pointer for arduino neopixels library so I can set it up in the setup function with dynamic variables?

I am using NeoPixel strips, and I want to be able to declare a pointer to them, but not initialize them until the setup function (because they will initialize with certain variables only made available in setup).

For simpler data types, I am just doing:

int totalNumColors = 4; //number of colors user can cycle through`
uint32_t* colorArray = new uint32_t[totalNumColors];
void setup() {
  for (int i=0;i<totalNumColors;i++){
    colorArray[i] = totalColorArray[i];
  }
}

How do I do this for NeoPixel strip intializers? I tried:

Adafruit_NeoPixel* pixels = new Adafruit_Neopixel;`

but I get the error:

expected type-specifier before 'adafruit neopixel'
Source Link
mheavers
  • 247
  • 6
  • 14

how to declare a pointer for arduino neopixels library so I can set it up in the setup function with dynamic variables

I am using neopixel strips, and I want to be able to declare a pointer to them, but not initialize them until the setup function (because they will initialize with certain variables only made available in setup.

For simpler data types, I am just doing:

int totalNumColors = 4; //number of colors user can cycle through`
uint32_t* colorArray = new uint32_t[totalNumColors];
void setup() {
  for (int i=0;i<totalNumColors;i++){
    colorArray[i] = totalColorArray[i];
  }
}

How do I do this for neopixel strip intializers? I tried:

Adafruit_NeoPixel* pixels = new Adafruit_Neopixel;

but I get the error:

expected type-specifier before 'adafruit neopixel'