For Loop for Duo LEDs (Shiftout)

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

i was wondering what language you used, i think your a starter so take a look at this digitalWrite() - Arduino Reference
digitalwrite is the command to set a pin.

Oh and btw it might be handy to do a modulo calculation
like
x = 10 % 5; // x now contains 0
x = 7 % 5; // x now contains 2
x = 9 % 5; // x now contains 4
x = 5 % 5; // x now contains 0
x = 4 % 5; // x now contains 4

so you can check if it is even uneven and dividable by 2 4 8 16 32 64 128 .. you can go that that binary pattern of counting do an if check if x=0 it was dividable.
5 % 4 = 1
5 % 2 =1

Im using the Shiftpwm Library. Im using 4 Shiftregisters to Drive 2x8 Duo LEDs (would be 32 normal LEDs).

Next step would be to fade in those LEDs but I have to solve the main problem first.

Any idea, anyone?

Any idea, anyone?

The usual one. Post ALL of your code. We can't tell from your snippet exactly what the problem is. Use the code tags, too, not the quote tags (use the icon with the # sign on it).