Hi all.
I am building LED controller with PicoBuck LED Module.
(product link : PicoBuck LED Driver - COM-13705 - SparkFun Electronics)
I've almost finished this project, but there's one Issue.
when I apply low duty cycle pwm signal to the LED Module, LED starts to flicker, which is not as I intended.
I want to know why this happens, and how to prevent flickering and maintain constant hue and brightness.
I hope videos and pictures explain my problem better, so here I leave some of them.
[LED Flickering]
-> (edit) it seems like there's problem with LED and Camera interferance.
If seen in my eye,
(1) no flickering at MAX brightness
(2) flickering in color and brightness, as input is slowly changed.
it seems duty cycle below 30 ~ 40% shows this flickering.
[Schematic of LED module and Arduino]
(Edit) Included everything inside this project. this box also sends signal to WS2812B LED Strip, which is 21 LED's long.
If more information is needed, please let me know.
[Prototype]
[arduino sourcecode]
#include <FastLED.h>
#define LED_R 9
#define LED_G 10
#define LED_B 11
#define STRIP_DIN 6
#define STRIP_LED_NUM 21
#define POT_R A0
#define POT_G A1
#define POT_B A2
#define PUSH_1 12
#define PUSH_2 13
#define RELAY 8
CRGB led[STRIP_LED_NUM];
bool push1_pressed_now = false;
bool push1_pressed_before = false;
bool push2_pressed_now = false;
bool push2_pressed_before = false;
bool led_on = false;
bool strip_on = false;
// Timing variables
unsigned long previousMillis = 0; // Stores the last time LEDs were updated
const long interval = 100; // Interval at which to update LEDs (in milliseconds)
// Stores previous potentiometer values to detect changes
int prev_R_brightness = 0;
int prev_G_brightness = 0;
int prev_B_brightness = 0;
bool is_button_pressed(int button_no, bool &check_now, bool &check_before);
void setup() {
pinMode(RELAY, OUTPUT);
Serial.begin(9600);
pinMode(LED_R, OUTPUT);
pinMode(LED_G, OUTPUT);
pinMode(LED_B, OUTPUT);
pinMode(POT_R, INPUT);
pinMode(POT_G, INPUT);
pinMode(POT_B, INPUT);
pinMode(PUSH_1, INPUT_PULLUP);
pinMode(PUSH_2, INPUT_PULLUP);
FastLED.addLeds<WS2812B, STRIP_DIN>(led, STRIP_LED_NUM);
for (int i = 0; i < STRIP_LED_NUM; i++) {
led[i] = CRGB::White;
FastLED.show();
delay(50);
}
for (int i = 0; i < STRIP_LED_NUM; i++) {
led[i] = 0;
FastLED.show();
delay(50);
}
}
void loop() {
unsigned long currentMillis = millis(); // Get the current time
// Check for button presses
if (is_button_pressed(PUSH_1, push1_pressed_now, push1_pressed_before)) {
led_on = !led_on;
}
if (is_button_pressed(PUSH_2, push2_pressed_now, push2_pressed_before)) {
strip_on = !strip_on;
}
// Read potentiometer values
int pot_R_val = analogRead(POT_R);
int pot_G_val = analogRead(POT_G);
int pot_B_val = analogRead(POT_B);
// decide threshold, 0 ~ 34
int R_brightness = pot_R_val/30;
int G_brightness = pot_G_val/30;
int B_brightness = pot_B_val/30;
// Apply threshold. if less than 90, turn off.
if (R_brightness < 3) { R_brightness = 0; }
if (G_brightness < 3) { G_brightness = 0; }
if (B_brightness < 3) { B_brightness = 0; }
// Update LED only if brightness changes AND some time passes
if ((currentMillis - previousMillis >= interval) &&
(R_brightness != prev_R_brightness || G_brightness != prev_G_brightness || B_brightness != prev_B_brightness)
)
{
previousMillis = currentMillis; // Update the time
digitalWrite(RELAY, led_on);
// Set the individual LED brightness, 0 ~ 34 -> 0 ~ 205
analogWrite(LED_R, led_on * 6 * R_brightness);
analogWrite(LED_G, led_on * 6 * G_brightness);
analogWrite(LED_B, led_on * 6 * B_brightness);
// Set the LED strip colors, 0 ~ 34 -> 0 ~ 255
for (int i = 0; i < STRIP_LED_NUM; i++) {
led[i].setRGB(strip_on *7.4* G_brightness, strip_on *7.4* B_brightness, strip_on *7.4* R_brightness);
// Swapping RGB channels to match the interpretation of the LED strip
}
FastLED.show();
Serial.print(" R : ");Serial.print(R_brightness);
Serial.print(" G : ");Serial.print(G_brightness);
Serial.print(" B : ");Serial.println(B_brightness);
// Store the current potentiometer values
prev_R_brightness = R_brightness;
prev_G_brightness = G_brightness;
prev_B_brightness = B_brightness;
}
}
// Function to detect if a button is pressed
bool is_button_pressed(int button_no, bool &check_now, bool &check_before) {
check_now = !digitalRead(button_no);
if (check_now && !check_before) {
check_before = check_now;
return true;
} else {
check_before = check_now;
return false;
}
}
[Similar Issue with same LED Module]


