#include <FastLED.h>
#include <OneButton.h>
int potpinh = A0;
int potpins = A1;
int potpinv = A2;
#define btnpin 2
#define btnpin2 3
#define NUM_LEDS 60
#define LED_PIN1 12
int huey; // variable to read the value from the analog pin
int statz;
int valz;
CRGB leds [NUM_LEDS];
uint8_t paletteIndex = 0;
uint8_t patternCounter = 0;
uint8_t index = 0;
int speed = 0;
uint8_t vance =0;
DEFINE_GRADIENT_PALETTE( GMT_cool_gp ) {
0, 0, 255, 255,
255, 255, 0, 255
};
CRGBPalette16 coolCoolool = GMT_cool_gp;
OneButton btn = OneButton(btnpin, true, true);
void setup() {
FastLED.addLeds<WS2812B, LED_PIN1, GRB>(leds, NUM_LEDS);
// FastLED.addLeds<WS2812B, LED_PIN2, GRB>(leds2, NUM_LEDS2);
FastLED.setBrightness(255);
// Serial.begin(19200);
btn.attachClick(nextPattern);
}
void switcheroo() {
switch (patternCounter) {
case 0:
raneboes();
break;
case 1:
tempNess();
break;
case 2:
slidey();
break;
}
}
void loop(){
switcheroo();
FastLED.show();
btn.tick();
uint8_t buh = 0;
CFastLED::getBrightness (buh);
Serial.println(buh);
}
void nextPattern() {
patternCounter = (patternCounter+1) % 3;
// Serial.println(String("patt") + patternCounter); // Change the number after the % to the number of patterns you have
}
void tempNess() {
EVERY_N_MILLISECONDS(250) {
huey = analogRead(potpinh);
huey = map(huey, 0, 1023, 0, 255);
// Serial.println(String("H: ") + huey);
statz = analogRead(potpins);
statz = map(statz, 0, 1023, 0, 255);
// Serial.println(String("S: ") + statz);
valz = analogRead(potpinv);
valz = map(valz, 0, 1023, 0, 255);
// Serial.println(String("V: ") + valz);
}
static uint8_t chase_pos = 0;
static uint8_t chase_fade_in = 0;
CHSV chase_colour = CHSV(huey, statz, valz);
// fade all LEDs towards black
fadeToBlackBy(leds, NUM_LEDS, 1);
// increase the fade in brightness, capping at 255
chase_fade_in = qadd8(chase_fade_in, 20);
// set the current pos to the chase colour
leds[chase_pos] = chase_colour;
// and dim it to the fade in level
fadeToBlackBy( & leds[chase_pos], 1, 255 - chase_fade_in);
// if fully faded in, start fading in the next LED
if (chase_fade_in == 255) {
chase_fade_in = 0;
chase_pos = (chase_pos + 1) % NUM_LEDS;
}
FastLED.show();
}
void raneboes() {
uint8_t position = beatsin8(30, 0, NUM_LEDS-1, 0, 0);
//fill_rainbow (struct CHSV *targetArray, int numToFill, uint8_t initialhue, uint8_t deltahue=5)
leds[position] = ColorFromPalette(RainbowColors_p,vance, 255, LINEARBLEND);
huey = analogRead(potpinh);
huey = map(huey, 0, 1023, 0, 1000 * 2);
// Serial.println(String("H: ") + huey);
// Serial.println(String("SP: ") + speed);
vance++;
fadeToBlackBy(leds, NUM_LEDS, 1);
FastLED.show();
}
void slidey(){
for (int i = 0; i <= NUM_LEDS - 1; i++) {
leds[i] = CRGB(0, 255, 8);
FastLED.delay(33);
leds[i] = CRGB::Black;
if(i==NUM_LEDS){
i = 0;
}
}
}
/*
void coolNess() {
EVERY_N_MILLISECONDS(250) {
huey = analogRead(potpinh);
huey = map(huey, 0, 1023, 0, 255);
Serial.println(String("H: ") + huey);
statz = analogRead(potpins);
statz = map(statz, 0, 1023, 0, 255);
Serial.println(String("S: ") + statz);
valz = analogRead(potpinv);
valz = map(valz, 0, 1023, 0, 255);
Serial.println(String("V: ") + valz);
}
static uint8_t chase_pos = 0;
static uint8_t chase_fade_in = 0;
chase_colour = fill_palette(leds, NUM_LEDS, 128, 255 / NUM_LEDS, coolCoolool, 128, LINEARBLEND);
// fade all LEDs towards black
fadeToBlackBy(leds, NUM_LEDS, 1);
// increase the fade in brightness, capping at 255
chase_fade_in = qadd8(chase_fade_in, 20);
// set the current pos to the chase colour
leds[chase_pos] = chase_colour;
// and dim it to the fade in level
fadeToBlackBy( & leds[chase_pos], 1, 255 - chase_fade_in);
// if fully faded in, start fading in the next LED
if (chase_fade_in == 255) {
chase_fade_in = 0;
chase_pos = (chase_pos + 1) % NUM_LEDS;
}
FastLED.show();
} */