Color Patterns
how can create pattern cycle through specific set of colors. wrote code manually forces colors change, want have pattern added loop , way have time not working properly
void c9_colors(){
leds[0] = crgb::white;
leds[1] = crgb::red;
leds[2] = crgb::green;
leds[3] = crgb(255,40,0);
leds[4] = crgb::blue;
leds[5] = crgb(255,150,0);
i want set leds cycle these 6 colors want every 6th led specific color keeps color pattern through 200 leds, not 200 leds red, white, green example. led 0 white, led 6 white , on. after 600ms led 0 becomes red , led 6 red , on through pattern , start on in loop
void c9_colors(){
leds[0] = crgb::white;
leds[1] = crgb::red;
leds[2] = crgb::green;
leds[3] = crgb(255,40,0);
leds[4] = crgb::blue;
leds[5] = crgb(255,150,0);
i want set leds cycle these 6 colors want every 6th led specific color keeps color pattern through 200 leds, not 200 leds red, white, green example. led 0 white, led 6 white , on. after 600ms led 0 becomes red , led 6 red , on through pattern , start on in loop
similar problem:
code: [select]
//walkingmarkeever2
#include <adafruit_neopixel.h>
#define wait 500 //viewing time
bool allowwalking = true; //true >>>---> allows colors walk
// false >>>---> stationary
#define ledcount 200 //total number of leds
#define pin 6 //output pin led strip
#define ledsperboard 6 //number of leds on pcb
int offset = 0; //offset or index colourarray[]
unsigned long colourarray[] = //colour code sequence
{
//example 1:
//red green blue pink yellow white cyan orange black
//0xff0000, 0x00ff00, 0x0000ff, 0xff00ff, 0xff7f00, 0xffffff, 0x00ffff, 0xff3000, 0x000000
//example 2:
//red green blue white
//0xff0000, 0x00ff00, 0x0000ff, 0xffffff
//example 3:
//red red green green blue blue pink pink white white
//0xff0000, 0xff0000, 0x00ff00, 0x00ff00, 0x0000ff, 0x0000ff, 0xff00ff, 0xff00ff, 0xffffff, 0xffffff
//example 4:
//red green blue pink yellow white
0x3f0000, 0x003f00, 0x00003f, 0x3f003f, 0x3f3f00, 0x3f3f3f //dimmer
//example 5:
//red green blue pink yellow white
//0xff0000, 0x00ff00, 0x0000ff, 0xff00ff, 0xff9f00, 0xffffff //bright
//example 6:
//red green blue
//0xff0000, 0x00ff00, 0x0000ff //bright
//example 7:
//red green blue
//0x3f0000, 0x003f00, 0x00003f //dimmer
};
//how many colours have
const byte availablecolors = sizeof(colourarray) / sizeof(unsigned long);
adafruit_neopixel strip = adafruit_neopixel(ledcount, pin, neo_grb + neo_khz800);
//***********************************************************************************
void setup()
{
strip.begin();
strip.show(); // initialize pixels 'off'
}// end of setup()
//***********************************************************************************
void loop()
{
//cycle through colours
for (byte colourselect = 0; colourselect < availablecolors; colourselect++)
{
//fill pixel array memory
for (byte lednumber = 0; lednumber < ledcount; lednumber++)
{
strip.setpixelcolor(lednumber, colourarray[offset]);
//the next index/offset colourarray[]
offset++;
offset = offset % availablecolors;
}// end of for()
//send pixel array memory leds
strip.show();
//give time view strip
delay(wait);
//*********************
//move next item in colourarray[]
if (allowwalking == true)
{
offset = colourselect;
}
//*********************
}// end of for()
}// end of loop()
//***********************************************************************************
Arduino Forum > Using Arduino > Programming Questions > Color Patterns
arduino
Comments
Post a Comment