I want to be able to change the number of LEDs per strip. In my project there will always be 8 zones, but the number of LEDs in each zone may change. I’m using (will be using) bluetooth to change various settings in the program, but I need you help.
//includes
#include <SoftwareSerial.h>
#include <FastLED.h>
SoftwareSerial BLE_Shield(4,5);
int knobPositions[6];
int switchPositions[3];
//define Zone pins
const int ZONES[8] = {6,7,8,9,10,11,12,13};
int numLEDsPerZone[8];
CRGB zoneLEDS[]={};
//define utility/led pins
int status_led = 2;
void setup() {
BLE_Shield.begin(9600);
//setup zones
for (int i=0; i < sizeof(ZONES); i++){
CRGB zoneLEDS[numLEDsPerZone[i]];
pinMode(ZONES[i],OUTPUT);
FastLED.addLeds<NEOPIXEL, ZONES[i]>(zoneLEDS, numLEDsPerZone[i]);
}
}
void loop() {
//read from the BLE Board, somehow... :/
/*if (BLE_Shield.available() >= 9) // this will only be true if there are at least 9 bytes to read
{
for (int i=0; i <=8 ; i++)
{
array[i] = BLE_Shield.read();
}
}*/
}
I get the error :
'ZONES' cannot appear in a constant-expression
What I’m trying to do is set the number of LEDs per zone and the pattern to display per zone. And then once i get the hang of that I want to be able to Serially feed other settings.
How do i set the number of LED per strip dynamically?
I think that that depends on what you mean by dynamically. Does that mean that the number of LEDs in a strip is going to change while the Arduino is running? How is that possible? Are you waving a soldering iron around wiring with voltage applied?
PaulS:
I think that that depends on what you mean by dynamically. Does that mean that the number of LEDs in a strip is going to change while the Arduino is running? How is that possible? Are you waving a soldering iron around wiring with voltage applied?
LOL!
No, basically i printed a board. I want to use it eventually with multiple projects, fiddling with the LED design.
So, 2 months down the line i may want LEDs in my living room, rather than my office and the space may require more or less strips of leds...
Should i just setup the board with the max number of LEDs per zone (i dont know what that would be) and set trailing LEDs (ghost LEDs) black and if they are trailing LEDs ignore them...is that efficient?
Couldn't you add an SD card that has configuration data?
The function you are using expects to know how many LEDs there are AT RUN TIME. That doesn't have to be a constant (known at compile time).
You could read the configuration file, and use malloc() to allocate memory, and populate the resulting "array" (you actually get a pointer back from malloc()), then pass the pointer to the addLeds() function.
PaulS:
Couldn't you add an SD card that has configuration data?
The function you are using expects to know how many LEDs there are AT RUN TIME. That doesn't have to be a constant (known at compile time).
You could read the configuration file, and use malloc() to allocate memory, and populate the resulting "array" (you actually get a pointer back from malloc()), then pass the pointer to the addLeds() function.
I have my prototype board printed already and i didnt think of that...
I’m reading through the EEPROM docs and do you know why i would want to update and address rather than reWrite to it?
Suppose you write with a pen on paper. Then, you try to erase what you wrote, using an appropriate eraser. There is damage to the paper, right? Well, writing to EEPROM involves erasing what was there, first, with some amount of damage. Only erasing what needs to be erased, so that it can be replaced with a new value, minimizes that wear.
ok so once set i would want to use update. BUT I think in my case i will want to use "avr/eeprom.h" so that i can save structs or data structures per zone, right?