Skip to content

Instantly share code, notes, and snippets.

@Tejkaran
Created October 5, 2016 16:45
Show Gist options
  • Save Tejkaran/575da5fd6d36f214b119ecd49a2a7ec1 to your computer and use it in GitHub Desktop.
Save Tejkaran/575da5fd6d36f214b119ecd49a2a7ec1 to your computer and use it in GitHub Desktop.
#include "FastLED.h"
#include <SPI.h>
#define NumPixels 150 // number of LEDs in strip - count starts at 0, not 1
#define DataRate_Mhz 12
#define DataPin 11
#define ClockPin 13
CRGB leds[NumPixels];
int r = 0;
int g = 0;
int b = 0;
int Up, Down;
int Count =0;
int Timer = 10000; //seconds to light up and down
void setup()
{
FastLED.addLeds<APA102,DataPin,ClockPin,BGR,DATA_RATE_MHZ(DataRate_Mhz)>(leds,NumPixels);
Serial.begin(115200); // set the speed at which serial monitor will write at
fill_solid(leds, NumPixels, CRGB(0,0,0)); // fill all black
FastLED.show(); // show
delay(2000); // saftey first
}
void loop()
{
for(Up=0; Up<=254; ++Up) // adds one at the end so do 254
{
switch (Count)
{
case 1: ++r; break; // red
case 2: ++r; ++g; break; // yellow
case 3: ++g; break; // green
case 4: ++g; ++b; break; // cyan
case 5: ++b; break; // blue
case 6: ++b; ++r; break; // purple
}
fill_solid(leds, NumPixels, CRGB(r,g,b)); // light up whole strip
FastLED.show(); // show
delay(Timer/255);
Down=255;
}
for(Down=255; Down>=1; --Down) // takes one at the end so do 1
{
switch (Count)
{
case 1: --r; break; // red
case 2: --r; --g; break; // yellow
case 3: --g; break; // green
case 4: --g; --b; break; // cyan
case 5: --b; break; // blue
case 6: --b; --r; break; // purple
}
fill_solid(leds, NumPixels, CRGB(r,g,b)); // light up whole strip
FastLED.show(); // show
delay(Timer/255);
Up = 0;
}
if(Count>=6)Count=0;
++Count;
Serial.print("Count = "); Serial.println(Count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment