Hello,
This is my first time posting here so I hope I do everything right. I am trying to get some help with some programming for an LED project I am working on. Disclaimer, I am brand new to coding and projects involving boards or MCUs. I have tried a lot of googling, but I end up with a lot of results that I can't understand due to their more advanced language or programming.
I am trying to learn how to control more than one LED (WS2812B) strip using a single ESP8266 ESP12. My project is basically a 3d printed statue that has the LEDs running inside of it creating light effects. I have currently gotten one LED strip working with code (basically just altered the cylon example code until it worked for me).
What I want to learn is how I can control a second LED strip. The first strip is off of data pin 3, so if I had a second LED strip off of data pin 4 how would I program that? For simplicity's sake, for the example we can just have them run the same code.
I have everything wired up the standard way, with a capacitor and resistor where they need to be. I know that I will need to get a stronger power supply when both are running, but I am just trying to figure the code out first (feasibility) before purchasing more.
Here is my code. If anything is unclear or there are issues please let me know.
[code]
#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 144
// 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 3
//#define CLOCK_PIN 13
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(57600);
Serial.println("resetting");
LEDS.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
LEDS.setBrightness(84);
}
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] = CHSV(hue++, 255, 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(10);
}
}
[/code]
Hardware:
LEDs (WS2812B RGB 5050SMD Individual Addressable)
Board (ESP8266 ESP-12)
Power Supply (5V 10A Power Supply Adapter)