Created
October 5, 2016 16:46
-
-
Save Tejkaran/fc14642e71f7f7838066608b7681b9d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "FastLED.h" | |
#include <SPI.h> | |
#define NumPixels 150 // number of LEDs in strip - count starts at 0, not 1 | |
#define DataRate_Mhz 12 // how fast data refreshes at | |
#define DataPin 11 // data pin | |
#define ClockPin 13 // clock Pin | |
CRGB leds[NumPixels]; | |
int r = 0, g = 0, b = 0; | |
int xy; | |
int Count = 0; | |
int Timer = 3000; // seconds to light up and down | |
int MaxBrightness = 100; // brightness desired, max 255 | |
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(xy=0; xy<=MaxBrightness-1; ++xy) // adds one at the end so do 254 | |
{ | |
switch (Count) | |
{ | |
case 1: if(b<=0)b; else{--b;}; ++r; break; // blue - purple - red | |
case 2: if(r<=0)r; else{--r;}; ++g; break; // red - yellow - green | |
case 3: if(g<=0)b; else{--g;}; ++b; break; // green - cyan - blue | |
} | |
fill_solid(leds, NumPixels, CRGB(r,g,b)); // light up whole strip | |
FastLED.show(); // show | |
delay(Timer/MaxBrightness); // delay lighting up one shade | |
} | |
if(Count>=3)Count=1; | |
else {++Count;} | |
xy=0; | |
Serial.print("Count = "); Serial.println(Count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment