Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- #define NUM_LEDS 24
- #define DATA_PIN 11
- #define CLOCK_PIN 13
- volatile uint8_t col = 0;
- // Define the array of leds
- CRGB leds[NUM_LEDS];
- void setup() {
- LEDS.addLeds<LPD8806,DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS).setDither(DISABLE_DITHER);
- memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));
- LEDS.setBrightness(64);
- }
- void loop() {
- // First slide the led in one direction
- for(int i = 0; i < NUM_LEDS; i++) {
- switch(col) {
- case 0: leds[i] = CRGB::Red; break;
- case 1: leds[i] = CRGB::Green; break;
- case 2: leds[i] = CRGB::Blue; break;
- }
- // Show the leds
- FastLED.show();
- leds[i] = CRGB::Black;
- delay(50);
- }
- // Now go in the other direction.
- for(int i = NUM_LEDS - 2; i >= 0; i--) {
- switch(col) {
- case 0: leds[i] = CRGB::Red; break;
- case 1: leds[i] = CRGB::Green; break;
- case 2: leds[i] = CRGB::Blue; break;
- }
- // Show the leds
- FastLED.show();
- leds[i] = CRGB::Black;
- delay(50);
- }
- FastLED.show();
- col++;
- if (col > 2) col = 0;
- delay(250);
- }
Advertisement
Add Comment
Please, Sign In to add comment