Hi,
in my code i want so set the color for a rgb led stripe. I use the WS2811Driver library.
I tried this but it doesn't work:
// blink_strip - ws2811 led strip blink example
// 11-15-2012 Initial Version 0.1
#include <WS2811Driver.h>
byte leds0[30];
byte leds1[30];
// 24 bits of color data stored GGRRBB
//const uint8_t leds0[] = { 0x00,0xff,0x00, 0xff,0x00,0x00, 0x00,0x00,0xff, 0xff,0xff,0xff }; // R,G,B,W
//const uint8_t leds1[] = { 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 }; // 0,0,0,0,
WS2811Driver ledStrip; // uses P1_7 as datapin connect to DIN on strip
void setup(void)
{
ledStrip.setLEDCount(10); // setup for 4 leds on a strip
ledStrip.begin(); // configure P1.7 for output
}
void loop() {
//ledStrip.write(leds0); // set leds to red,green,blue,white
//delay(500);
//ledStrip.write(leds1,sizeof(leds1)); // turn off all 4 leds
//delay(500);
String color = "0000FF";
for(byte x = 0; x < 30 ; x++){
leds0[x] = byte('F');
//leds0[x+1] = byte(color.substring(2,3));
//leds0[x+2] = byte(color.substring(4,5));
}
ledStrip.write(leds0);
delay(5000);
for(byte x = 0; x < 30 ; x++){
leds1[x] = 0x00;
//leds0[x+1] = byte(color.substring(2,3));
//leds0[x+2] = byte(color.substring(4,5));
}
ledStrip.write(leds1);
delay(5000);
}
How can I convert the string to 3 bytes?