Hi I have a working completed project that I made using code that did the same thing on a smaller project but I have recently upgraded it to have more RGB's(I use the ws2812b) and an additional strand. These are controlled by buttons and they all work just fine. Only problem is there is some issue with the code that I can't debug, I am an entry level programmer and got a pro to write the code for me(lesept) but did'nt really need these colors (mainly red) in that project but now that I have made a new project with more RGB's the red is an issue. Here is a fritz of the project. Replace the ws2812b's in it with the small ones like a dime in size with only three wires a ground a data and a power.
and now here is the code.!
#include <FastLED.h>
#include <JC_Button.h> // https://github.com/JChristensen/JC_Button
/*
No copyright, use it at your own risks ;-)
*/
// Define the arrays of leds
#define PIN_STRIP1 2
#define PIN_STRIP2 4
#define PIN_STRIP3 3
#define COLOR_ORDER RGB
#define LED_TYPE WS2812
#define NUM_LEDS 8
#define NUM_LEDS2 4
uint8_t max_bright = 255;
struct CRGB leds1[NUM_LEDS];
struct CRGB leds2[NUM_LEDS];
struct CRGB leds3[NUM_LEDS2];
//Colors for strip 1 using CRGB constants from FastLED library
int ledColor1[8] = {CRGB::Blue,CRGB::Blue,CRGB::Green,CRGB::Green,CRGB::Blue,CRGB::Blue,CRGB::Green,CRGB::Green}; // Color for strip 1
int ledColor2[8] = {CRGB::Purple,CRGB::Purple,CRGB::Purple,CRGB::Purple,CRGB::Blue,CRGB::Blue,CRGB::Blue,CRGB::Blue}; // Color for strip 2
int ledColor3[4] = {CRGB::Green,CRGB::HotPink,CRGB::Cyan,CRGB::Orange};
// Define buttons
const byte
PIN_BUTTON1 (12),
PIN_BUTTON2 (11),
PIN_BUTTON3 (10),
PIN_BUTTON_RESET (9);
Button BUTTON1(PIN_BUTTON1);
Button BUTTON2(PIN_BUTTON2);
Button BUTTON3(PIN_BUTTON3);
Button BUTTON_RESET(PIN_BUTTON_RESET);
// Global vars
int NumStrip1 = 0;
int NumStrip2 = 0;
int NumStrip3 = 0;
void setup() {
LEDS.addLeds<LED_TYPE, PIN_STRIP1, COLOR_ORDER>(leds1, NUM_LEDS);
LEDS.addLeds<LED_TYPE, PIN_STRIP2, COLOR_ORDER>(leds2, NUM_LEDS);
LEDS.addLeds<LED_TYPE, PIN_STRIP3, COLOR_ORDER>(leds3, NUM_LEDS2);
FastLED.setBrightness(max_bright);
FastLED.clear();
FastLED.show();
BUTTON1.begin();
BUTTON2.begin();
BUTTON3.begin();
BUTTON_RESET.begin();
}
void loop() {
Checkbuttons();
}
void Checkbuttons()
{
BUTTON1.read(); // read BUTTON1
if (BUTTON1.wasReleased()) ChangeStrip1 ();
BUTTON2.read(); // read BUTTON2
if (BUTTON2.wasReleased()) ChangeStrip3 ();
BUTTON3.read(); // read BUTTON3
if (BUTTON3.wasReleased()) ChangeStrip2 ();
BUTTON_RESET.read(); // read Reset BUTTON
if (BUTTON_RESET.wasReleased()) ResetStrips ();
}
void ChangeStrip1 () {
leds1[NumStrip1] = ledColor1[NumStrip1];
NumStrip1 = min(NumStrip1 + 1, NUM_LEDS - 1);
FastLED.show();
}
void ChangeStrip2 () {
leds2[NumStrip2] = ledColor2[NumStrip2];
NumStrip2 = min(NumStrip2 + 1, NUM_LEDS - 1);
FastLED.show();
}
void ChangeStrip3 () {
leds3[NumStrip3] = ledColor3[NumStrip3];
NumStrip3 = min(NumStrip3 + 1, NUM_LEDS2 - 1);
FastLED.show();
}
void ResetStrips () {
FastLED.clear();
NumStrip1 = 0;
NumStrip2 = 0;
NumStrip3 = 0;
FastLED.show();
}
If any one can see why the color RED is not appearing that would be great. In general the RGB's are not doing the full spectrum but getting red is all i am after I need it for the Dreaded Mythos Phase. This is a phase tracker for the Game Arkham Horror 3rd Edition. Here is a picture of the almost completed project.
Any help getting these ws2812b geekcriet RGB's from Banggood lighting up RED would be greatly appreciated.