Hi,
I want to use a couple of Duo LEDs to show a value. LED 0 to 5 green, LED 6 to 11 yellow and 12 to 15 red.
My value is 0 to 255.
I have 16 LEDs so I divide the 255 through 17. This gives me a maximum Value of 15,perfect.
void setLED(int value){
int ledgroup = (value/17);int green=ledgroup;
for (int i=0; i <=5 || i<= green; i++){
ledgroup--;
ShiftPWM.SetGroupOf2(i,255,0);
}
int yellow=ledgroup;
for (int i=6; i <=11 || i<= yellow; i++){
ledgroup--;
ShiftPWM.SetGroupOf2(i,255,255);
}
int red=ledgroup;
for (int i=12; i <=15 || i<= red; i++){
ledgroup--;
ShiftPWM.SetGroupOf2(i,0,255);
}
So, If my value is 170, I divide it through 17 and get 10. This means 11 LEDs (0 to 11) should light up. So it starts at the first for loop. Turns on 0 to 5 and subtracts 1 every time its in the loop. Then it goes to the next loop (with ledgroup=yellow=4) and turns on LED 6 to 9....
But anyhow. This piece of code doesnt work! If I swap the ShiftPWM command with
Serial.println("step1");
Serial.println(ledgroup,DEC);
and so on... it prints "step1" and stops!. nothing more, nothing less.
any suggestions?
-tsaG