So I am just trying to make an array of objects of my custom class bcLED and I am getting the error. error: no match for 'operator=' (operand types are 'bcLed' and 'bcLed*')
Can some one tell me why? I know it will be something simple.
also why i am here is there a way to create an array of an unspecified length in C++ and then just append it with an new row each time I want to add an object to it?
void PopulateLEDS(){
int i;
bcLed ledArr[17];
for (i = 0; i< 16; i++)
{
ledArr[i] = new bcLed();
ledArr[i].id = i;
ledArr[i].charge = 0;
}
}
OK so i need more help
To avoided creating ten thousand posts I am going to paste the main body of the code so that to see where I am tripping up with the C++ syntax.
the lattest errors are
/Users/bencawley/Documents/Arduino/Test/Bens_Lights/Bens_Lights.ino: In function 'void PopulateLEDS()':
Bens_Lights:49: error: expected primary-expression before 'public'
public:bcLed ledArr[17];
^
Bens_Lights:52: error: 'ledArr' was not declared in this scope
ledArr[i].id = i;
^
/Users/bencawley/Documents/Arduino/Test/Bens_Lights/Bens_Lights.ino: In function 'void BensPattern(uint8_t)':
Bens_Lights:69: error: 'ledArr' was not declared in this scope
strip.setPixelColor(i,0, 0, ledArr[i].charge, 0);
^
Using library Adafruit_NeoPixel at version 1.0.6 in folder: /Users/bencawley/Documents/Arduino/libraries/Adafruit_NeoPixel
exit status 1
expected primary-expression before 'public'
And my code is:
class bcLed{
public:int id;
public:int charge;
void incCharge(int amt)
{
charge = charge+amt;
if(charge >= 255){charge = 255;}
}
};
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
PopulateLEDS();
}
void loop() {
// Some example procedures showing how to display to the pixels:
BensPattern(45);
}
void PopulateLEDS(){
int i;
bcLed ledArr[17];
for (i = 0; i< 17; i++)
{
ledArr[i].id = i;
ledArr[i].charge = 0;
}
}
void BensPattern(uint8_t wait)
{
uint16_t i, j;
int rn = rand() % strip.numPixels() ;
for (i = 0; i<strip.numPixels(); i++)
{
strip.setPixelColor(i,0, 0, 0, 0);
}
for (i = 0; i<rn; i++)
{
strip.setPixelColor(i,0, 0, ledArr[i].charge, 0);
ledArr[i].incCharge(1);
}
strip.show();
delay(wait);
}