EVERY_N_MILLISECONDS(50 {
leds[0] = CHSV(160, random8(), random8(100,255));
for(int i = NUM_LEDS - 1; i < 0; i--){
leds[i]= leds[i-1];
}
}
void fade_brightness()
{
//first give each a color
for(int i = 0; i < NUM_LEDS; i++)
{
leds[i].r=random(0,255); //random is in the Arduino library. Sends back a
random number between 0 and its argument, inclusive.
leds[i].g=random(0,255); //One way to set the color of the LEDs to a custom
color.
leds[i].b=random(0,255);
}
for(int i = MAX_BRIGHTNESS; i>0; i--)
{
FastLED.setBrightness(i);
FastLED.delay(1);
}
}
void blink_alternating_lights()
{
for(int j = 0; j < 10; j++)
{
for(int i=0; i < NUM_LEDS; i++)
{
if(i%2==0)
leds[i]=CRGB::DarkCyan;
else
leds[i]=CRGB::DarkGoldenrod;
}
FastLED.delay(100);
for(int i=0; i < NUM_LEDS; i++)
{
if(i%2==0)
leds[i]=CRGB::DarkGoldenrod;
else
leds[i]=CRGB::DarkCyan;
}
FastLED.delay(100);
}
for(int i = 0; i<NUM_LEDS; i++){
leds[i] = CRGB::Black;
FastLED.delay(100);
}
for(int i = 0 ; i<NUM_LEDS; i++){
if(i%2 == 0){
leds[i]= CRGB::DarkGoldenrod;
}else{
leds[i] = CRGB::DarkCyan;
}
FastLED.delay(100);
}
}
one blur
uint8_t sinBeat = beatsin8(30,0, NUM_LEDS - 1,0,0);
leds[sinBeat] = CRGB::Blue;
fadeToBlackBy(leds,NUM_LEDS,10);
EVERY_N_MILLISECONDS(10){
Serial.println(sinBeat);
}
FastLED.show();
3 lights
uint8_t sinBeat = beatsin8(30,0, NUM_LEDS - 1,0,0);
uint8_t sinBeat2 = beatsin8(30,0, NUM_LEDS - 1,0,85);
uint8_t sinBeat3 = beatsin8(30,0, NUM_LEDS - 1,0,170);
leds[sinBeat] = CRGB::Blue;
leds[sinBeat2] = CRGB::Red;
leds[sinBeat3] = CRGB::White;
fadeToBlackBy(leds,NUM_LEDS,10);
EVERY_N_MILLISECONDS(10){
Serial.println(sinBeat);
Serial.print(",");
Serial.println(sinBeat2);
Serial.print(",");
Serial.println(sinBeat3);
}
FastLED.show();
single wave
//Waves for LED PoSition
uint8_t posBeat = beatsin8(30,0, NUM_LEDS - 1,0,0);
uint8_t posBeat2 = beatsin8(60,0, NUM_LEDS - 1,0,0);
//Wave for LED Color
uint8_t colBeat = beatsin8(45,0, 255,0,0);
leds[(posBeat + posBeat2)/ 2] = CHSV(colBeat,255,255);
fadeToBlackBy(leds,NUM_LEDS,10);
FastLED.show();
symmetrical wave
//Waves for LED PoSition
uint8_t posBeat = beatsin8(30,0, NUM_LEDS - 1,0,0);
uint8_t posBeat2 = beatsin8(60,0, NUM_LEDS - 1,0,0);
uint8_t posBeat3 = beatsin8(30,0, NUM_LEDS - 1,0,127);
uint8_t posBeat4 = beatsin8(60,0, NUM_LEDS - 1,0,127);
//Wave for LED Color
uint8_t colBeat = beatsin8(45,0, 255,0,0);
leds[(posBeat + posBeat2)/ 2] = CHSV(colBeat,255,255);
leds[(posBeat3 + posBeat4)/ 2] = CHSV(colBeat,255,255);
fadeToBlackBy(leds,NUM_LEDS,10);
FastLED.show();
pallete wave
uint8_t posBeat = beatsin8(30,0, NUM_LEDS - 1,0,0);
uint8_t posBeat2 = beatsin8(60,0, NUM_LEDS - 1,0,0);
fill_palette(leds, NUM_LEDS,(posBeat + posBeat2)/2, 0, orangePink, 255,
LINEARBLEND);
FastLED.show();
DEFINE_GRADIENT_PALETTE(browngreen_gp){
21, 31, 52, 255,
42, 82, 152, 255,
88, 139, 194, 255,
250, 103, 29, 255,
235, 71, 15, 255,
164, 29, 10, 255,
};
CRGBPalette16 orangePink = browngreen_gp;
moving palette
fill_palette(leds, NUM_LEDS,paletteIndex, 255/ NUM_LEDS, orangePink, 255,
LINEARBLEND);
FastLED.show();
EVERY_N_MILLISECONDS(10){
paletteIndex++;
}
random palette
EVERY_N_MILLISECONDS(50){
//switch on an led at random, choosing from random color form palette
leds[random8(0,NUM_LEDS - 1)] = ColorFromPalette(orangePink, random8(),
255,LINEARBLEND);
}
fadeToBlackBy(leds, NUM_LEDS, 1);
for loop palette {
uint8_t paletteIndex[NUM_LEDS];
in setup function
for(int i =0; i<NUM_LEDS;i++){
paletteIndex[i] = random8();
}
for(int i =0; i<NUM_LEDS;i++){
leds[i] = ColorFromPalette(orangePink, paletteIndex[i]);
}
EVERY_N_MILLISECONDS(5){
for(int i =0; i<NUM_LEDS;i++){
paletteIndex[i]++;
}
}
FastLED.show();
}
// lights.cpp - Lights buffer handling
//
// Adapted from code by John Graham-Cumming by Alison N. Norman
//
#include "lights.h"
// leds_init: Initializes leds to all pixels off and mirrors
// that to the actual display
void leds_init()
{
for ( int x = 0; x < NUM_LEDS + 1; ++x )
leds[x] = CRGB::Black;
FastLED.show();
}
// leds_scroll: scroll the leds left one column
void leds_scroll()
{
for ( int x = 1; x < NUM_LEDS + 1; ++x ) {
leds[x-1] = leds[x];
}
FastLED.show();
}
void test_leds()
{
for(int j = 0; j < 2; j++)
{
for(int i=0; i < NUM_LEDS; i++)
{
if(i%2==0)
leds[i]=CRGB::SteelBlue;
else
leds[i]=CRGB::PaleVioletRed;
}
FastLED.delay(700);
for(int i=0; i < NUM_LEDS; i++)
{
if(i%2==0)
leds[i]=CRGB::PaleVioletRed;
else
leds[i]=CRGB::SteelBlue;
}
FastLED.delay(700);
}
}
//tests.cpp - learn how to control the lights here!
//by Alison N. Norman
#include "tests.h"
//blink the light closest to the controller
void blink_light_0_example()
{
leds[0]= CRGB::Red; //defined in colors (pixeltypes.h), sets led 0 to white in
strand
FastLED.delay(1000); //pauses the program for the specified number of
milliseconds
//do this to display the current light settings for a
particular amount of time
//calls show, which mirrors the values in leds to the strand
leds[0]=CRGB::Black; //Black turns the led off
FastLED.delay(1000);
//Function to blink the first and last lights
void blink_lights_0_and_24()
{
leds[0].red = 255;
leds[24].blue = 255;
FastLED.delay(100);
leds[0]=CRGB::Black; //Black turns the led off
leds[24]=CRGB::Black;
FastLED.delay(1000);
//Function to blink all lights
void blink_all_lights()
{
for(int i = 0; i<NUM_LEDS; i++){
leds[i] = CRGB::Green;
}
FastLED.delay(1000);
for(int i = 0; i<25; i++){
leds[i] = CRGB::Black;
}
FastLED.delay(100);
}
//Function to blink every other light
void blink_alternating_lights()
{
for(int j = 0; j < 10; j++)
{
for(int i=0; i < NUM_LEDS; i++)
{
if(i%2==0){
leds[i]=CRGB::DarkCyan;}
else{
leds[i]=CRGB::DarkGoldenrod;
}
}
FastLED.delay(100);
for(int i=0; i < NUM_LEDS; i++)
{
if(i%2==0){
leds[i]=CRGB::DarkGoldenrod;}
else{
leds[i]=CRGB::DarkCyan;}
}
FastLED.delay(100);
}
for(int i = 0; i<NUM_LEDS; i++){
leds[i] = CRGB::Black;
FastLED.delay(100);
}
for(int i = 0 ; i<NUM_LEDS; i++){
if(i%2 == 0){
leds[i]= CRGB::DarkGoldenrod;
}else{
leds[i] = CRGB::DarkCyan;
}
FastLED.delay(100);
}
//Function to fade the brightness of all
void fade_brightness()
{
//first give each a color
for(int i = 0; i < NUM_LEDS; i++)
{
leds[i].r=random(0,255); //random is in the Arduino library. Sends back a
random number between 0 and its argument, inclusive.
leds[i].g=random(0,255); //One way to set the color of the LEDs to a custom
color.
leds[i].b=random(0,255);
}
for(int i = MAX_BRIGHTNESS; i>0; i--)
{
FastLED.setBrightness(i);
FastLED.delay(1);
}
}
void chase()
{
for(int i = 0; i<25; i++){
if(i == 0){
leds[0] = CRGB::Green;
leds[24] = CRGB::Black;
} else {
leds[i] = CRGB::Green;
leds[i-1] = CRGB::Black;
}
FastLED.delay(40);
}
}
void chase_two_colors_with_scroll()
{