Neopixel All Flash
i'm trying head around how neopixel library works, , have 4 gems want blink @ same time. put each gem on it's own pin, , put them in array.
my question because i'm learning how harness power of neopixels! code wasn't sloppy. example, should messing brightness turn off, or set rgb 0,0,0?
my question because i'm learning how harness power of neopixels! code wasn't sloppy. example, should messing brightness turn off, or set rgb 0,0,0?
code: [select]
#include <adafruit_neopixel.h>
#define pin2 2 // cyclotron upper left light
#define pin3 3 // cyclotron upper right light
#define pin4 4 // cyclotron lower left light
#define pin5 5 // cyclotron lower left light
#define cyc_led_num 8 // # of leds on each cyclotron gem (12???)
int rotatenum = 0; // rotates between cyclotron lights
int = 0; // counter initalizing gems in setup()
// parameter 1 = number of pixels in strip
// parameter 2 = pin number (most valid)
// parameter 3 = pixel type flags, add needed:
// neo_khz800 800 khz bitstream (most neopixel products w/ws2812 leds)
// neo_khz400 400 khz (classic 'v1' (not v2) flora pixels, ws2811 drivers)
// neo_grb pixels wired grb bitstream (most neopixel products)
// neo_rgb pixels wired rgb bitstream (v1 flora pixels, not v2)
// adafruit_neopixel(parameter1, parameter2, neo_grb + neo_khz800)
adafruit_neopixel cyclopins[] = {
adafruit_neopixel(cyc_led_num, pin2, neo_grb + neo_khz800),
adafruit_neopixel(cyc_led_num, pin3, neo_grb + neo_khz800),
adafruit_neopixel(cyc_led_num, pin4, neo_grb + neo_khz800),
adafruit_neopixel(cyc_led_num, pin5, neo_grb + neo_khz800),
};
void setup() {
serial.begin(9600); // serial print (testing)
for(i=0;i<3;i++){
cyclopins[i].begin(); // prepare data pin neopixel output
cyclopins[i].show(); // initializes neopixels initial "off" state in case left lit prior program
}
//serial.print(" show#: ");
//serial.print(i);
}
void loop() {
//cycblinkfade(); // each gem lights , fades repeating sequence
cycoverheat(); // 4 gems flash red specified amount of time
rotateled(); // iterates next gem
}
void rotateled(){
if(rotatenum < 3){
rotatenum++;
} else {
rotatenum=0;
}
serial.print(" rotatenum#: ");
serial.print(rotatenum);
}
// each gem lights , fades repeating sequence
void cycblinkfade(){
for(int i=0; i<cyc_led_num; i++){
cyclopins[rotatenum].setbrightness(255);
cyclopins[rotatenum].setpixelcolor(i, 255,0,0); // red // setpixelcolor(n, red, green, blue)
}
cyclopins[rotatenum].show();
for(int y=255;y>=0;y--){
cyclopins[rotatenum].setbrightness(y); // change brightness next time through loop:
cyclopins[rotatenum].show();
delay(4);
}
//delay(500); // turn on add delay
}
void cycoverheat(){
for(int oh=0;oh<3;oh++){
cyclopins[oh].setbrightness(255);
for(int i=0; i<cyc_led_num; i++){
cyclopins[oh].setpixelcolor(i, 255,0,0); // red // setpixelcolor(n, red, green, blue)
}
cyclopins[oh].show();
}
delay(300);
for(int oh=0;oh<3;oh++){
cyclopins[oh].setbrightness(0);
for(int i=0; i<cyc_led_num; i++){
cyclopins[oh].setpixelcolor(i, 255,0,0); // red // setpixelcolor(n, red, green, blue)
}
cyclopins[oh].show();
}
delay(300);
}
...i have 4 gems want blink @ same time. put each gem on it's own pin, , put them in array.they typically wired in series, attached single pin , dealt library.
Arduino Forum > Using Arduino > Programming Questions > Neopixel All Flash
arduino
Comments
Post a Comment