I'm attaching my build and the code below in hopes that someone can find what the problem is. Everything seems to be working, except when I hold down the button to switch between brightness modes and it gets to the "brightness = 200" part, I see smoke coming from the 5V 24LED WS2812B ring. At one point the 10k resistor from the button got fried also. I'm not very good at electronics, this is just a hobby for me, so simple explanations are appreciated.
#include <FastLED.h>
#include <ezButton.h>
#define LED_PIN1 5
#define LED_PIN2 6
#define NUM_LEDS 48
int BRIGHTNESS = 200; // 0 - 255
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
// IR
int IRpin = 7; // PIN for IR Sensor
int obstacleCheck = HIGH; // HIGH means no obstacle
// BUTTON
const int BUTTON_PIN = 2; // the number of the pushbutton pin
ezButton button(BUTTON_PIN); // create ezButton object that attach to pin
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN1, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<LED_TYPE, LED_PIN2, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setMaxPowerInVoltsAndMilliamps(5, 3000); // 5V 3A limit
randomSeed(analogRead(0));
// IR STUFF
pinMode(IRpin, INPUT);
// BUTTON STUFF
button.setDebounceTime(10); // set debounce time
button.setCountMode(COUNT_FALLING);
}
void loop()
{
// MUST call the loop() function first
button.loop();
// Constantly read the IR pin status
obstacleCheck = digitalRead(IRpin);
// IF IR SENSOR IS COVERED LEDS GO DARK AND RESET COUNT, ELSE GO THROUGH COUNT MODES
if (obstacleCheck == LOW)
{
button.resetCount();
for(int i=0; i<NUM_LEDS; i++){
leds[i] = CHSV(0, 0, 0);
}
FastLED.show();
}
else
{
// Tracks which button mode we are in
int count = button.getCount();
// Counter while button is held down
int myCount = 1;
// While button is held down
while(button.getStateRaw() && count == 0){
myCount++;
if(myCount == 500) {
BRIGHTNESS = 10;
}
if(myCount == 700) {
BRIGHTNESS = 40;
}
if(myCount == 900) {
BRIGHTNESS = 70;
}
if(myCount == 1100) {
BRIGHTNESS = 100;
}
if(myCount == 1300) {
BRIGHTNESS = 150;
}
if(myCount == 1500) {
BRIGHTNESS = 200;
break;
}
FastLED.setBrightness(BRIGHTNESS);
FastLED.show();
}
if(count == 0){
fill_solid(leds, NUM_LEDS, CHSV(100, 0, BRIGHTNESS));
FastLED.show();
} else if(count == 1){
FastLED.clear();
function_mode1();
} else if(count == 2){
FastLED.clear();
function_mode2();
} else if(count == 3){
FastLED.clear();
function_mode3();
} else if(count == 4){
FastLED.clear();
fill_solid(leds, NUM_LEDS, CHSV(100, 0, BRIGHTNESS));
FastLED.show();
button.resetCount();
}
}
}
void function_mode1(){
// Some light pattern here
}
void function_mode2(){
// Some light pattern here
}
void function_mode3(){
// Some light pattern here
}