DIY Led "Studio" light for recording flicker problems

Hello, there I'm using the 12v 5630 led strips with my project driving them with the arduino for dimming aka. to get different color temperatures. The problem is it flickers a lot no matter what duty cycle I use. I use pins 9 and 10 for the PWM. I thought about either changing the PWM frequency or using some sort of a filter? Can someone give me guidance?(my code is down below)

led_controller.ino (12.7 KB)

Hi. Please read the forum guide in the sticky post. This will tell you how to post code correctly, and what else to include in your post, such as a schematic and links to the specs of the components you are using.

https://pastebin.com/xH5TukZM

Here is my code. Ts is a pastebin because it said the message is too long. That is all I could see is missing from the guidelines. If there is something else please say.

Erikthegamer:
It is a pastebin because it said the message is too long.

It is indeed.

This is partly due to using variable names that are too explanatory. It would for example be quite sufficient to use "WW" and "CW" instead of "warm_white" and "cold_white" and similar contractions so that "cold_white_button_minus_last_debounce_time" becomes "CW_btn_mns_lst_deb_time".

Secondly, I see many repeated chunks of code. These should be made into functions. Code that is unnecessarily long or repetitive makes it more difficult to comprehend and therefore, difficult to debug. If you can sort that out and put it into a post, it will be (more?) practical for us to review it. :grinning:

It looks like you are using analogWrite() unconditionally in loop(), so it is getting called hundreds of times per second. I seem to remember this can cause flickering. Only call analogWrite() when the value has changed. Keep the previous value and compare it with the new value. Only call analogWrite() if they differ.

I have 'optimized' my code so that it is below 9000 char but the forum still won't allow it so here is the 'optimized' pastebin:#include <PT6961.h>//Variables:int WW_pwm = 0;int CW_pwm = 0;int CW_driv - Pastebin.com (at this point you can hate me I can't be more bothered).

It looks like you are using analogWrite() unconditionally in loop(), so it is getting called hundreds of times per second. I seem to remember this can cause flickering. Only call analogWrite() when the value has changed. Keep the previous value and compare it with the new value. Only call analogWrite() if they differ.

Still haven't got around to trying that but will tomorrow. Also arduino I'm using is the nano v3 clone with atmega 328(sorry don't have the money for the real one). And is there any other way I could remove the flicker like a filter circuit(any link would be helpful) or using an adjustable buck converter with a smart potentiometer(i. think that is how it's called but I am not sure).

Erikthegamer:
And is there any other way I could remove the flicker like a filter circuit

Clearly not.

PaulRB has it pinned.