# Fluctuating brightness in RGB-LED strand controlled by Arduino

I am controlling the three colors of an RGB strand using PWM output from an Arduino UNO (via IRF520N MOSFETs). When the signal to the LEDs is in midrange, the strand starts to visibly pulsate at a rate of about 10Hz or less. When the colors are on full load, the pulsating disappears. Eliminating one color at a time also mitigates or eliminates the pulsating.

After considering other options (the power supply is steady as a rock and designed for LED strands, for example), my working theory is that the brightness of the combined LEDs exhibits a "beat" effects as it is known in acoustics: when two notes of similar frequency are struck together, the ear can hear an audible fluctuation in volume. I was able to simulate a similar effect with rectangle waves mathematically:

Question: Is this a reasonable theory, and -- other than limiting myself to seven colors -- how can this effect be mitigated to the extend of not being annoying anymore? If I want to use the LED strip as mood lighting, this sure is going to ruin it...

• Probably all your PWM channels run from the same clock, so they can't beat with each other. Plus you wouldn't see it by eye even if they were at different frequencies. Oct 29, 2023 at 18:12
• The beat frequency is the difference in the frequency between the two PWM clocks, in this case you estimated that one must be 10 Hz faster than the other. However, if you only have one microcontroller with a single clock, then the beat frequency would be f1-f1=0 Hz and the beat would be at DC, not 10 Hz. Also, you won't be able to see the beat frequency by eye for a lot of complicated reasons about how interference patterns are generated. Oct 29, 2023 at 18:58
• And yet I observe the beat pattern, so the only other explanation would be the switching in the transistors. Oct 29, 2023 at 19:10
• Probe the power to your transistor and microcontroller with an oscilloscope. I'd also check Vgs as well when you see the flickering. You may not be adequately decoupled somewhere. Oct 29, 2023 at 19:24
• You've suggested that the supply is steady. As a check that pulsating is not caused by PWM beating against a line frequency harmonic , alter PWM period slightly and see if beat frequency changes. Oct 29, 2023 at 19:31

In this answer I will assume you have an Uno up to rev 3.

For a start, the FET is not a logic level one. An Arduino Uno runs at 5 V, the IRF520N need more to fully switch on. Example of a better choice is IRLB8721.

About PWM frequency, this is what it looks like:

PWM Pins
3, 5, 6, 9, 10, 11

PWM Frequency
490 Hz (pins 5 and 6: 980 Hz)

Source: Arduino Reference

Hz is not very high for PWM, but at least there's two variants here for you to experiment with.

• Thanks for the hardware tip! I noticed that there is a breakout board for the Arduino using the 520, and I could not find any alternative in all the Arduino/LED articles I found. I knew the 520 needs 9V, but I thought you need the 9V only if you want to run the full 9A. However, my trouble starts at the lower end of about 500mA and goes away as I start to hit 2A. Definitely going to try your recommendation, though! Oct 30, 2023 at 0:33
• With the IRF520N the RDS(on) is much higher when gate is driven with 3.3 V and you want more punch for the load, not for the heatsink of the FET. || But I say the PWM frequency could be better for your application. It can be done with the Arduino though, search for arduino pwm frequency increase. Oct 30, 2023 at 0:38
• So, ahm, yes - I experienced some trepidation about mucking about at that low a level, but apparently that did, indeed, the trick. The strand, with all color combos, now dims without pulsating from "off" to "too bright to stare into for long." That was not bleeding obvious, so much the greater is my gratitude for sending me on that route. Someone else in the comments above also mentioned it as a thing to try, so thank you as well, but at the time I was still too timid to try it. Oct 30, 2023 at 1:36