#define FASTLED_ALLOW_INTERRUPTS 0 // Used for ESP8266.
#include "FastLED.h" // FastLED library.
#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif
// Fixed definitions cannot change on the fly.
#define LED_DT 7
#define COLOR_ORDER GRB // It's GRB for WS2812B and GBR for APA102
#define LED_TYPE WS2812B // What kind of strip are you using (APA102, WS2801 or WS2812B)?
#define NUM_LEDS 6 // Number of LED's
#define button 3 // pin to the button
int mode=0;
// Initialize changeable global variables.
uint8_t max_bright = 100; // Overall brightness definition. It can be changed on the fly.
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
void setup() {
Serial.begin(115200);
LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // For WS2812B
FastLED.setBrightness(max_bright);
FastLED.setMaxPowerInVoltsAndMilliamps(5, 1000); // FastLED power management set at 5V, 500mA
FastLED.clear();
FastLED.show();
//setup buttons
pinMode(button, INPUT_PULLUP);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
} // setup()
//void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
void loop() {
static uint8_t hue = 0;
Serial.print("x");
// First slide the led in one direction
for(int i = 0; i < NUM_LEDS; i++) {
// Set the i'th led to red
leds[i] = CRGB(0, 0, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
//leds[i] = CRGB::Black;
//fadeall();
// Wait a little bit before we loop around and do it again
delay(150);
}
// Now go in the other direction.
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
leds[i] = CRGB::Black;
delay(10);
}
{
//digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
//delay(1000); // wait for a second
//digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
//delay(1000); // wait for a second
digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}
}