Brightness difference in LED Strip

Hello,
I recentky started a project where i am controlling my led lights with buttons and rotary encoders. Today I was messing with using rotary encoders to change the brightness and when the brightness is maxed out at 255 the lights seemed dimmer than it usually, and didn't seem light it was at full brightness. I took of a picture of part of the light that the Arduino was controlling and part that it wasn't and there was a big difference in brightness, Why does this happen and how can I fix it? Thank you

Here is my code,

#include <FastLED.h>
#include <Encoder.h>
#include "Arduino.h"
#include "NewEncoder.h"
#define LED_PIN 10
#define NUM_LEDS 180
#define button 4
CRGB leds[NUM_LEDS];
Encoder knobLeft(2, 6);
Encoder knobRight(3, 4);
int newLeft, newRight;

void makeStripe() {
  switch (newLeft) {
    case 0: for (int i=0; i<NUM_LEDS; i++){  leds[i] = CRGB(0, 0, 0);
        FastLED.show();
    } break;
    case 1: fill_solid(leds, NUM_LEDS, CRGB::Blue);
        FastLED.show(); break;
    case 2: fill_solid(leds, NUM_LEDS, CRGB::Red);
        FastLED.show(); break;
    case 3: fill_solid(leds, NUM_LEDS, CRGB::Green);
        FastLED.show(); break;
    case 4: fill_solid(leds, NUM_LEDS, CRGB::Blue);
        FastLED.show(); break;
    case 5: fill_solid(leds, NUM_LEDS, CRGB(23, 33, 222));
        FastLED.show(); break;
    case 6: fill_solid(leds, NUM_LEDS, CRGB::White);
        FastLED.show(); break;
   
  }
  FastLED.show();
  FastLED.setBrightness(newRight);
}
void setup() {
  FastLED.addLeds<WS2811, LED_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setMaxPowerInVoltsAndMilliamps(5, 500);
  FastLED.clear();
  FastLED.show();
  
  pinMode (button, INPUT_PULLUP);
    Serial.begin(9600);
  Serial.println("TwoKnobs Encoder Test:");
  
  
  
}

long positionLeft  = -999;
long positionRight = -999;

void loop() {
static bool buttonOld = 1;
  bool state = digitalRead(button);
  if (buttonOld != state) {
    delay(200);
    buttonOld = state;
    if (!state) {
    
}       
}
    
  newLeft = knobLeft.read() / 4;
   if(newLeft > 20){
    knobLeft.write(20*4);
    }
  if(newLeft < 1){
    knobLeft.write(4);
    }
  newRight = knobRight.read();
  if(newRight > 255){
    knobRight.write(255);
    }
  if(newRight < 1){
    knobRight.write(4);
    }
  if (newLeft != positionLeft || newRight != positionRight) {
    Serial.print(newLeft);
    Serial.print(newRight);
    Serial.println();
    positionLeft = newLeft;
    positionRight = newRight;
   makeStripe();
  }
  // if a character is sent from the serial monitor,
  // reset both back to zero.
  if (Serial.available()) {
    Serial.read();
    Serial.println("Reset both knobs to zero");
    
  }
    
    }

Here is the diffidence, it is more noticeable in person

20210627_235320

Probably not your solution but you should verify the strips are getting the full 5V. I know LEDs do not dim all the same.

Do you power your strip approximately every 60 leds from the power supply?

Yeah, I have 3 cables powering the led strips plus when I disconnect the arduino and recover the led strip it becomes a lot brighter

It sounds like a software malfunction, really. It's a pity those WS2812 strips cannot be easily monitored using e.g. an oscilloscope as that would give some clues. The first thing that comes to mind is that despite your careful catching of out-of-bound brightness values (i.e. <1 and >255), somewhere in your code an overflow still occurs. I can imagine that the checking for >255 doesn't work entirely as intended as you don't really limit the knob parameter to its upper bound of 255, but instead read its value and display 255 if it's >255. This could still make it roll over if you keep turning the rotary encoder.

I figured it out , it was becasue of this piece of code

FastLED.setMaxPowerInVoltsAndMilliamps(5, 500);

I forgot that the lights are running off of 12v and not 5v, dumb mistake on my part. Thank you for your help!

I don't think that would cause different LEDs to show different colours or brightness. I think it would only affect the overall brightness of the strip.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.