Can some one please Help with addressable LED sketch I need?
I have tried your sketch and only the first 9 out of 16 led’s light up.
I would like to make the led’s start at 0 and go to 16 and start over again in the color white, I know it is probably no big deal for some one that knows how to do this but its my first time using addressable LED’s and making sketch’s.
The data pin I’am using is #3 and my board is Mini Nano V3.0 ATmega328P 5V 16M Micro Controller Board Module Arduino.
@Anx_Xna - I just complied it on a Uno and it compiles correctly. I do not have a Nano handy but if it compiles on an Uno then it will compile on a Nano. Did you download the four files in:
This code is close to what I need, if I can figure out how to make only 2 lights go round and round. #include <FastLED.h>
#define NUM_LEDS 9 #define DATA_PIN 3
int FrameDelay = 40;
int colorBarPosition = 1;
int frameCounter = 0;
//list of colors these are RGB hex colors
long colorPallet[] = {
CRGB::White,
};
// calculate number of colors in the array, needed later
int numberofColors=(sizeof(colorPallet)/sizeof(colorPallet[0]));
// calculate color bar length based on number of leds
int colorBarLength = (NUM_LEDS/numberofColors)*1;
int palletPosition = 0;
bool clearLEDS = false;
// setup LED array
CRGBArray<NUM_LEDS> leds;
void setup()
{
delay(9000);
// sanity delay for recovery if needed
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.clear();
FastLED.setBrightness (50);
FastLED.show();
}
void loop()
{
EVERY_N_MILLISECONDS(FrameDelay)
{
// loop to shift LED values lower the array
for (int x=0; x<NUM_LEDS-1; x++)
{
leds[x] = leds[x+1];
}
// set last LED to the correct color based on color bar position and color bar length
if ((colorBarPosition <= colorBarLength) && !clearLEDS)
{
leds[NUM_LEDS-1] = colorPallet[palletPosition];
colorBarPosition++;
}
// check pallet position and bar position if at the end of both, start clear process
if ((palletPosition == numberofColors-1) && (colorBarPosition > colorBarLength) && !clearLEDS)
{
//set last LED to black(0x000000)
leds[NUM_LEDS-1]=CRGB::Black;
// reset variables to start for bar positions
palletPosition = 0;
colorBarPosition = 1;
//set clear LEDS flag to complete clearing
clearLEDS= true;
}
if ((colorBarPosition > colorBarLength) && !clearLEDS)
{
// reset bar position and step to next color
colorBarPosition = 1;
palletPosition = palletPosition+1;
}
// check if clearing process is complete, if so clear flag
if (clearLEDS && !leds(0,NUM_LEDS-1))
{
clearLEDS = false;
}
}
FastLED.show ();
}
it will work, but I will put the police one in 1 folder and try it, how do I get it to see the folder.
@Anx_Xna - I have just posted a new sketch in GitHub Gist that contains only the function, cd77_police_lights_one_modified, from my original sketch, CD77_Police_Lights. It is located at:
Change the variables in line 38 to get the effects that you want.