#include <FastLED.h>
static struct PIPE {
char x, gap_y;
unsigned int col;
} mypipe;
unsigned long lastTimeUpdate = millis();
#define NUM_LEDS 10
#define LED_PIN 27
CRGB leds[NUM_LEDS];
uint8_t colorIndex[NUM_LEDS];
// Gradient palette "ibcso_bath_gp", originally from
// http://seaviewsensing.com/pub/cpt-city/ibcso/tn/ibcso-bath.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 80 bytes of program space.
DEFINE_GRADIENT_PALETTE( ibcso_bath_gp ) {
0, 1, 4, 13,
106, 1, 4, 13,
106, 1, 10, 28,
127, 1, 10, 28,
127, 2, 19, 50,
148, 2, 19, 50,
148, 4, 31, 79,
170, 4, 31, 79,
170, 5, 47,119,
191, 5, 47,119,
191, 9, 80,158,
212, 9, 80,158,
212, 17,125,203,
233, 17,125,203,
233, 19,146,223,
244, 19,146,223,
244, 31,152,214,
249, 31,152,214,
249, 54,166,216,
255, 54,166,216};
CRGBPalette16 autumnrose = ibcso_bath_gp;
void setup() {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(50);
//Fill the colorIndex array with random numbers
for (int i = 0; i < NUM_LEDS; i++) {
colorIndex[i] = random8();
}
Serial.begin(115200);
}
void loop() {
//Creat a sin wave with period of 2 seconds (30bpm) to change the brightness of the strip
uint8_t sinBeat = beatsin8(30, 50, 255, 0, 0);
// Color each pixel from the palette using the index from colorIndex[]
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette(autumnrose, colorIndex[i], sinBeat);
}
EVERY_N_MILLISECONDS(5){
for (int i = 0; i < NUM_LEDS; i++) {
colorIndex[i]++;
}
}
FastLED.show();
if (millis() - lastTimeUpdate > 3000) { // 1minute
mypipe.x = -10;
mypipe.gap_y = random(0, 20);
Serial.println(mypipe.x);
Serial.println(mypipe.gap_y);
lastTimeUpdate = millis();
}
}