Moderators: adafruit_support_bill, adafruit
strand.setPixelColor(5, strand.Color(255, 0, 0)); // set pixel #5 Red
strand.setPixelColor(6, strand.Color(0, 255, 0)); // set pixel #6 Green
strand.setPixelColor(7, strand.Color(0, 0, 255)); // set pixel #7 Blue
strand.setPixelColor(8, strand.Color(255, 255, 255)); // set pixel #8 White
strand.setPixelColor(9, strand.Color(0, 0, 0)); // set pixel #9 Blackadafruit_support wrote:To set a single pixel, use the "setPixelColor(pixel, color)" function. The 'pixel' parameter is the number of the pixel you want to set and 'color' is the RGB color you want to set it to. The "Color(r, g, b)" function is used to create the RGB color value.
For example:
- Code: Select all
strand.setPixelColor(5, strand.Color(255, 0, 0)); // set pixel #5 Red
strand.setPixelColor(6, strand.Color(0, 255, 0)); // set pixel #6 Green
strand.setPixelColor(7, strand.Color(0, 0, 255)); // set pixel #7 Blue
strand.setPixelColor(8, strand.Color(255, 255, 255)); // set pixel #8 White
strand.setPixelColor(9, strand.Color(0, 0, 0)); // set pixel #9 Black
how would I go about making some code like what came with the demos
adafruit_support wrote:how would I go about making some code like what came with the demos
Have you read the code that comes with the demos? You will notice that it mostly makes use of the "for" statement to create the patterns. The 'for' statement is documented here: http://arduino.cc/en/Reference/For
void colorChase(uint32_t c, uint8_t wait);strand.setPixelColor(5, strand.Color(255, 0, 0)); // set pixel #5 Red
strand.setPixelColor(6, strand.Color(0, 255, 0)); // set pixel #6 Green
strand.setPixelColor(7, strand.Color(0, 0, 255)); // set pixel #7 Blue
strand.setPixelColor(8, strand.Color(255, 255, 255)); // set pixel #8 White
strand.setPixelColor(9, strand.Color(0, 0, 0)); // set pixel #9 BlackHow would one not only address each LED indivually but also set its brightness in the same line?
long color, hue, saturation, level;
hue = 0; //0 - 1536 where 0=red 512=green 1024=blue
saturation = 255; //0 - 255 where 255 is full colour, and 0 is white
level = 255; 0 - 255: where 255 is brightest, and 0 is dimmest
color = hsv2rgb(hue, saturation, level);
strand.setPixelColor(0, strand.Color(color >> 16, color >> 8, color));adafruit_support wrote:Yes - mostly. The catch is that neither the leds nor your retinas respond linearly. You will have to experiment a bit to find the value the "looks" like half intensity.
uint32_t fade_color(uint32_t color, int decay, int current, float BIAS) {
//Decompose
byte g = color >> 16 & 0x7f;
byte r = color >> 8 & 0x7f;
byte b = color & 0x7f;
//do our math
float thisDecay = pow( (((float)decay) - current) / decay, log(BIAS)/log(0.5) );
g = (byte) ((float) g) * thisDecay;
r = (byte) ((float) r) * thisDecay;
b = (byte) ((float) b) * thisDecay;
//recompose and return
return (g << 16) + (r << 8) + b;
}Return to Glowy things (LCD, LED, TFT, EL) purchased at Adafruit
Users browsing this forum: adafruit_support_mike and 9 guests