Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Arduino.h"
- #include <FastLED.h>
- FASTLED_USING_NAMESPACE
- #define NUM_LEDS 60
- CRGB rawleds[NUM_LEDS];
- const int virtualleds[10]
- { 2, // 1
- 7, // 2
- 0, // 3
- 4, // 4
- 12, // 5
- 3, // 6
- 11, // 7
- 1, // 8
- 15, // 9
- 13 // 10
- } ;
- #define BRIGHTNESS 100
- #define FRAMES_PER_SECOND 120
- void rainbow();
- void my_fill_rainbow( struct CRGB * pFirstLED, int numToFill, int *virtualleds,
- uint8_t initialhue,
- uint8_t deltahue );
- void setup()
- {
- // initialize LED digital pin as an output.
- FastLED.addLeds<NEOPIXEL, 6>(rawleds, NUM_LEDS);
- FastLED.setBrightness(BRIGHTNESS);
- }
- uint8_t gHue = 0; // rotating "base color" used by many of the patterns
- void loop()
- {
- // send the 'leds' array out to the actual LED strip
- FastLED.show();
- // insert a delay to keep the framerate modest
- FastLED.delay(1000/FRAMES_PER_SECOND);
- // do some periodic updates
- EVERY_N_MILLISECONDS( 1 ) { gHue++; } // slowly cycle the "base color" through the rainbow
- rainbow();
- }
- void rainbow()
- {
- // my modified FastLED's built-in rainbow generator
- my_fill_rainbow( rawleds, 10, virtualleds, gHue, 7);
- }
- void my_fill_rainbow( struct CRGB * pFirstLED, int numToFill, int *virtualleds,
- uint8_t initialhue,
- uint8_t deltahue )
- {
- CHSV hsv;
- hsv.hue = initialhue;
- hsv.val = 255;
- hsv.sat = 240;
- for( int i = 0; i < numToFill; i++) {
- int virtualled=virtualleds[i];
- pFirstLED[virtualled] = hsv;
- hsv.hue += deltahue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement