Hi all,
I am trying to create a chasing code sequence for my 60-LED Pololu strip, using the Arduino Leonardo. I need white lights to chase in one direction, and blue lights to chase in the opposite direction, on some kind of timer. I am a novice, and I’ve hit a wall. Any help would be much appreciated.
Eileen
/* LedStripGradient: Example Arduino sketch that shows
* how to control an Addressable RGB LED Strip from Pololu.
*
* To use this, you will need to plug an Addressable RGB LED
* strip from Pololu into pin 12. After uploading the sketch,
* you should see a white LED moving along the strip
*/
#include <PololuLedStrip.h>
// Create an ledStrip object on pin 12.
PololuLedStrip<12> ledStrip;
// Create a buffer for holding 120 colors. Takes 360 bytes.
#define LED_COUNT 60
rgb_color colors[LED_COUNT];
int blue_led = LED_COUNT - LED_COUNT;
int white_led = LED_COUNT - 1;
void setup()
{
// set all LEDs to be off ("black")
for(byte i = 0; i < LED_COUNT; i++)
{
colors[i] = (rgb_color){0, 0, 0};
}
}
void loop()
{
// Update the colors.
colors[white_led] = (rgb_color){0, 0, 0}; // turn off previous white LED
colors[blue_led] = (rgb_color){0, 0, 0}; // turn off previous blue LED
white_led = (white_led + 2)%LED_COUNT; // increment white LED position
blue_led = (blue_led - 2)%LED_COUNT; // decrement blue LED position
colors[white_led] = (rgb_color){150, 150, 150}; // set new LED to be white
colors[blue_led] = (rgb_color){0, 20, 150}; // set new LED to be blue
// Write the colors to the LED strip. It takes about 8 ms to update 120 LEDs (4m)
ledStrip.write(colors, LED_COUNT);
delay(500); // changing this delay will change the speed of your LED
}