Smooth Spectrum for an RGB LED

I want to share this modification to the RGB tutorial since it was fun and looks nice. This RGB LED which came with the Adafruit ARDX kit is actually just a packaging of 3 LEDs sharing a common lead on one side. Controlling it is (almost) exactly the same as controlling 3 separate LEDs. It’s important to note that this particular RGB LED is common anode(+) which in the end means that unlike the other tutorials, 5V ==> Off; 0V ==> Max brightness.

Anyway here is some code that continuously and smoothly runs the LED through a (basically) non-repeating spectrum.  It’s not random but it will appear random to the human eye. Importantly, the steps are smooth so there are no sudden shifts in color or brightness.

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です