I'm at a loss as to why this won't work and I've been pulling my hair out all week!
I've taken this section of code from a larger project that it's not operating properly in.
The wiring is completely correct, as both the demoreel100 script and blink scripts work perfectly fine from the fast led examples.
Any help is appreciated! Also: yes I do need to store the values in a duplicate location as floats as part of the larger project. The program compiles totally fine, but then completely halts. Also, I'm running this on an arduino mega.
Thank you!!!
#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 50
// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 6
#define CLOCK_PIN 13
float x_red[2] {HUE_RED, 220.00};
float x_blue[2] {HUE_BLUE, 220.00};
float x_orange[2] {15.00, 255.00};
float x_purple[2] {206.00, 255.00};
float x_yellow[2] {25.00, 255.00};
float x_green[2] {HUE_GREEN, 220.00};
// Define the array of leds
CRGB leds[NUM_LEDS];
typedef struct {float h;float s;float v;} Float_arr;
Float_arr f[NUM_LEDS];
void set_led(int pixel, float hue, float sat, float val)
{
// if(hue < 0){hue = f[pixel].h;}
// if(sat < 0){sat = f[pixel].s;}
// if(val < 0){val = f[pixel].v;}
leds[pixel].setHSV((int)hue, (int)sat, (int)val);
// led_ref[pixel] = {hue, sat, val};
f[pixel] = {hue, sat, val};
//delay(1);
}
void setup()
{
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
for (int i = 0; i < NUM_LEDS; i += 7)
{
set_led(i, x_red[0], x_red[1], 255);
set_led(i + 1, x_blue[0], x_blue[1], 255);
set_led(i + 2, x_orange[0], x_orange[1], 255);
set_led(i + 3, x_purple[0], x_purple[1], 255);
set_led(i + 4, x_yellow[0], x_yellow[1], 255);
set_led(i + 5, x_green[0], x_green[1], 255);
set_led(i + 6, 0,0,0);
}
FastLED.show();
delay(100);
}
void loop() {
// Turn the LED on, then pause
leds[0] = CRGB::Red;
FastLED.show();
delay(500);
// Now turn the LED off, then pause
leds[0] = CRGB::Black;
FastLED.show();
delay(500);
}