Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- //---BEAMBOX---//
- The controllable Light Tower!
- Code by PerfectPixel
- Instructable at: http://www.instructables.com/id/BeamBox-A-tower-that-glows-to-your-commands/
- //-------------//
- Feel free to copy this code and do what you like with it, no credit necessary!!
- */
- #include "FastLED.h"
- int r = 255; // To start the fading at a particular color, simply input that color here!
- int g = 0;
- int b = 0;
- int i = 0;
- #define NUM_LEDS 7 //Change this to the number of LEDs in your tower
- #define DATA_PIN 9 //This is the pin that the LEDs are on
- CRGB leds[NUM_LEDS];
- void setup(){
- delay(2000);
- // !!! Uncomment one of the following lines for your leds arrangement: !!! //
- // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
- FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
- // FastLED.addLeds<WS2811_400, DATA_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<P9813, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
- // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
- }
- void loop() {
- if(r > 0 && b == 0){ //This bit does the fading for you
- r--;
- g++;
- }
- if(g > 0 && r == 0){
- g--;
- b++;
- }
- if(b > 0 && g == 0){
- r++;
- b--;
- }
- for(i = 0; i < NUM_LEDS; i++){
- leds[i].setRGB( r, g, b); //Sets the values of the LEDs.
- }
- FastLED.show();
- delay(100); //Change this to determine the speed of the fading
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement