Created
October 5, 2016 15:22
-
-
Save Tejkaran/5a88926461025b18e4293a2aaea9ddfc 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 | |
#define DataPin 11 | |
#define ClockPin 13 | |
CRGB leds[NumPixels]; | |
int r = 0; | |
int g = 0; | |
int b = 0; | |
int rUp, rDown, gUp, gDown, bUp, bDown; | |
int Count =0; | |
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() | |
{ | |
switch(Count) | |
{ | |
case 0: | |
if(r==0) | |
{ | |
for(rUp=0; rUp<=254; ++rUp) //r adds one at the end so do 254 | |
{ | |
++r; // increase brightness | |
fill_solid(leds, NumPixels, CRGB(r,g,b)); // light up whole strip | |
FastLED.show(); // show | |
delay(25); | |
rDown=255; | |
} | |
} | |
if(r>=255) | |
{ | |
for(rDown=255; rDown>=1; --rDown) // r takes one at the end so do 1 | |
{ | |
--r; // increase brightness | |
fill_solid(leds, NumPixels, CRGB(r,g,b)); // light up whole strip | |
FastLED.show(); // show | |
delay(25); | |
rUp = 0; | |
} | |
} | |
++Count; | |
break; | |
case 1: | |
if(g==0) | |
{ | |
for(gUp=0; gUp<=254; ++gUp) // g adds one at the end so do 254 | |
{ | |
++g; // increase brightness | |
fill_solid(leds, NumPixels, CRGB(r,g,b)); // light up whole strip | |
FastLED.show(); // show | |
delay(25); | |
gDown=255; | |
} | |
} | |
if(g>=255) | |
{ | |
for(gDown=255; gDown>=1; --gDown) // g takes one at the end so do 254 | |
{ | |
--g; // increase brightness | |
fill_solid(leds, NumPixels, CRGB(r,g,b)); // light up whole strip | |
FastLED.show(); // show | |
delay(25); | |
gUp = 0; | |
} | |
} | |
++Count; | |
break; | |
case 2: | |
if(b==0) | |
{ | |
for(bUp=0; bUp<=254; ++bUp) // b adds one at the end so do 254 | |
{ | |
++b; // increase brightness | |
fill_solid(leds, NumPixels, CRGB(r,g,b)); // light up whole strip | |
FastLED.show(); // show | |
delay(25); | |
bDown=255; | |
} | |
} | |
if(b>=255) | |
{ | |
for(bDown=255; bDown>=1; --bDown) // b takes one at the end so do 254 | |
{ | |
--b; // increase brightness | |
fill_solid(leds, NumPixels, CRGB(r,g,b)); // light up whole strip | |
FastLED.show(); // show | |
delay(25); | |
bUp = 0; | |
} | |
} | |
Count=0; | |
break; | |
} | |
Serial.print(Count); Serial.println("something");Serial.print(" Count="); Serial.println(Count); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment