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