Hi,
I currently have a sketch (running on an esp8266 board, a Wemos D1 Mini) that recieves data from Adafruit IO and uses that data to set specific leds on a WS2812B strip to a specific hue value. EG, if the sketch recieves "01244" it will set led 1 on the strip to hue value 244. Im the FastLED library to acheive this. However, instead of turning on individual leds, I would like to create "groups" of say, 6 leds and set them all at once, for example "01244" would target leds 1-6, "02244" would target leds 7-12. Im at a loss how to acheive this though, since I have very little experience with programming languages, so id appreciate any pointers/advice you can offer.
Heres my current code:
#include "config.h"
#include <FastLED.h>
AdafruitIO_Feed *smartLamp = io.feed("smartLamp"); // Set up smartLamp feed
CRGB leds[ledNum];
void setup() {
FastLED.addLeds<NEOPIXEL, ledPin>(leds, ledNum); // Set up LEDS
Serial.begin(115200); // Start serial connection
while(! Serial); // Waits for serial monitor.
Serial.print("Connecting to Adafruit IO");
io.connect(); // Connect to Adafruit IO
smartLamp->onMessage(setLed); // Attaches smartLamp feed to setLed function
while(io.status() < AIO_CONNECTED) { // Wait for connection
Serial.print(".");
delay(500);
}
Serial.println();
Serial.println(io.statusText()); // Connected
smartLamp->get();
}
void loop() {
io.run(); // Adafruit IO magic
}
void setLed(AdafruitIO_Data *data) { // Function is called when data is received from Adafruit IO
String stringData = data->toString();
Serial.println("stringData: " + stringData);
String ledData = stringData.substring(0,2);
String hueData = stringData.substring(stringData.length() - 3);
Serial.println("ledData: " + ledData);
Serial.println("hueData: " + hueData);
leds[ledData.toInt()] = CHSV(hueData.toInt(), 255, 255);
FastLED.show();
}
And the contents of the config file
#define ioUsername "xxxxxxxxxxxxxxx" // Adafruit IO username
#define ioKey "xxxxxxxxxxxxxxxxx" // Your Adafruit IO API key
#define wifiKey "xxxxxxxxxxxxxxxxx" // Your networks SSID
#define wifiPass "xxxxxxxxxxxxxxxx" // Your networks password
#define ledPin 4 // Pin leds are connected to.
#define ledNum 60 // Number of LEDS
#include "AdafruitIO_WiFi.h"
AdafruitIO_WiFi io(ioUsername, ioKey, wifiKey, wifiPass);