hi
I need to understand the following code on using 2 ws2803 led drivers with arduino
[quote]
[color=#7E7E7E]// WS2803_test[/color]
[color=#7E7E7E]// By Thomas Olson[/color]
[color=#7E7E7E]// teo20130202.01[/color]
[color=#7E7E7E]// WS2803 18 channel LED driver[/color]
[color=#7E7E7E]// Arduino 5V 16Mhz[/color]
[color=#7E7E7E]// WS2803 pin4 CKI - > ws2803_clockPin[/color]
[color=#7E7E7E]// WS2803 pin5 SDI - > ws2803_dataPin[/color]
[color=#7E7E7E]// WS2803 pin2 IREF = Rext to GND.[/color]
[color=#7E7E7E]// WS2803 pin6-23 = OUT0-17[/color]
[color=#7E7E7E]// According to the documentation...[/color]
[color=#7E7E7E]// WS2803 will receive 144 bits(18 bytes), latching it to itself[/color]
[color=#7E7E7E]// and then relay further bits to the next WS2803.[/color]
[color=#7E7E7E]//[/color]
[color=#7E7E7E]// But in fact, if you send more than 18 bytes say 36, then the[/color]
[color=#7E7E7E]// first 18 bytes are passed on to the second WS2803. And the next 18 bytes[/color]
[color=#7E7E7E]// are displayed in the first WS2803. And this is the behavior that is indicated[/color]
[color=#7E7E7E]// in timing chart (Fig 4.) of the documentation.[/color]
[color=#7E7E7E]//[/color]
[color=#7E7E7E]// This test code assumes two WS2803 in the chained together.[/color]
[color=#7E7E7E]// We will see that the second WS2803 displays the 1st-18th bytes sent and[/color]
[color=#7E7E7E]// the first WS2803 will display the 19th-36th bytes.[/color]
[color=#7E7E7E]// So...[/color]
[color=#7E7E7E]// The byte order is 0-17. The bit order is MSB-LSB. The chip order is Last to First.[/color]
[color=#CC6600]const[/color] [color=#CC6600]int[/color] ws2803_clockPin = 7;
[color=#CC6600]const[/color] [color=#CC6600]int[/color] ws2803_dataPin = 8;
#define nLEDs 36
uint8_t ledBar[nLEDs]; [color=#7E7E7E]// Array representing LED PWM levels (byte size)[/color]
[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() {
[color=#CC6600]pinMode[/color](ws2803_clockPin, [color=#006699]OUTPUT[/color]);
[color=#CC6600]pinMode[/color](ws2803_dataPin, [color=#006699]OUTPUT[/color]);
[color=#7E7E7E]// Initialize WS2803 - Clock needs to be low at least 600us to prepare itself.[/color]
[color=#CC6600]digitalWrite[/color](ws2803_clockPin, [color=#006699]LOW[/color]);
[color=#CC6600]delayMicroseconds[/color](600);
[color=#7E7E7E]// Initialize the ledBar array - all LEDs OFF.[/color]
[color=#CC6600]for[/color]([color=#CC6600]int[/color] wsOut = 0; wsOut < nLEDs; wsOut++){
ledBar[wsOut] = 0x00;
}
loadWS2803();
}
[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]() {
[color=#7E7E7E]// Simple test - Flash All LEDs ON/OFF[/color]
[color=#CC6600]for[/color]([color=#CC6600]int[/color] wsOut = 0;wsOut < nLEDs; wsOut++){
ledBar[wsOut] = 0xFF; [color=#7E7E7E]// Full ON [/color]
}
loadWS2803();
[color=#7E7E7E]// Then turn them ALL off[/color]
[color=#CC6600]for[/color]([color=#CC6600]int[/color] wsOut = 0; wsOut < nLEDs; wsOut++){
ledBar[wsOut] = 0x00; [color=#7E7E7E]// Full OFF[/color]
}
loadWS2803();
[color=#CC6600]delay[/color](1000);
[color=#7E7E7E]// Simple test - LED Chaser[/color]
[color=#CC6600]for[/color]([color=#CC6600]int[/color] wsOut = 0; wsOut < nLEDs; wsOut++){
ledBar[wsOut] = 0x3C; [color=#7E7E7E]// 23% brightness[/color]
loadWS2803();
[color=#CC6600]delay[/color](100); [color=#7E7E7E]// ON time for each LED during chase.[/color]
ledBar[wsOut] = 0x00; [color=#7E7E7E]// Full OFF[/color]
loadWS2803();
}
[color=#CC6600]delay[/color](1000);
[color=#7E7E7E]/* [/color]
[color=#7E7E7E]// Simple test - increase brightness to max and then dim to min each LED[/color]
[color=#7E7E7E] for(int wsOut = 0; wsOut < nLEDs; wsOut++){[/color]
[color=#7E7E7E] for(int iOut = 0; iOut < 256; iOut++){ // brighten one LED[/color]
[color=#7E7E7E] ledBar[wsOut] = iOut;[/color]
[color=#7E7E7E] loadWS2803();[/color]
[color=#7E7E7E] }[/color]
[color=#7E7E7E] for(int iOut = 0; iOut < 256; iOut++){ // now dim that one LED[/color]
[color=#7E7E7E] ledBar[wsOut] = (uint8_t)0xFF & 255-iOut;[/color]
[color=#7E7E7E] loadWS2803();[/color]
[color=#7E7E7E] }[/color]
[color=#7E7E7E] }[/color]
[color=#7E7E7E] delay(1000);[/color]
[color=#7E7E7E]*/[/color]
} [color=#7E7E7E]//loop[/color]
[color=#CC6600]void[/color] loadWS2803(){
[color=#CC6600]for[/color] ([color=#CC6600]int[/color] wsOut = 0; wsOut < nLEDs; wsOut++){
[color=#CC6600]shiftOut[/color](ws2803_dataPin, ws2803_clockPin, [color=#006699]MSBFIRST[/color], ledBar[wsOut]);
}
[color=#CC6600]delayMicroseconds[/color](600); [color=#7E7E7E]// 600us needed to reset WS2803s[/color]
}
[/quote]
I ain't a noob in coding but I need help with the for statements and hexadecimal thingys