#include <FastLED.h>
#define DATA_PIN 11
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS 10
CRGB leds[NUM_LEDS];
#define BRIGHTNESS 255
//---------------------------------------------------------------
// This sketch uses JChristensen's Button Library from:
// https://github.com/JChristensen/JC_Button
//
#include "JC_Button.h" // Include Button library
// Setup the push buttons
Button Button1(3, 100, false, false);
Button Button2(4, 100, false, false);
//---------------------------------------------------------------
void setup() {
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
Button1.begin(); // initialize the button object
Button2.begin(); // initialize the button object
Serial.println("Setup done.\n");
}
//---------------------------------------------------------------
void loop()
{
Button1.read(); // check the state of the button
Button2.read(); // check the state of the button
if(Button1.isPressed()) {
fill_rainbow( leds, NUM_LEDS, millis()/10 );
}
else if(Button2.isPressed()) {
EVERY_N_MILLISECONDS(500) {
fill_solid( leds, NUM_LEDS, CHSV(random8(),255,255) );
}
}
else {
FastLED.clear(); // clear all pixel data (ie. set all pixels off)
}
FastLED.show(); // display the pixels
}//end_main_loop