RGB LED Glow Flower

by alecmiller in Circuits > LEDs

512 Views, 1 Favorites, 0 Comments

RGB LED Glow Flower

IMG_20170908_153819.jpg

After noticing how well filament diffused light, and having about a hundred RGB LEDs lying around, I decided to make an RGB LED glowing flower. The process of making it was pretty straightforward, and the code was only a couple hours of work to get it tweaked right, but I'm very happy with the results.

Assembly

Radiant_Blossom__preview_featured.jpg

I used a standard non-diffused common cathode (shared ground) RGB LED, with the three positive legs in series with resistors and tied to pins RA0-2 on an HPC Curiosity Board.

The choice of what to put the LED in is up to you, I personally used the Radiant Blossom model by areynolds15 on Thingiverse. I recommend using white filament using a low fill density to allow the light to pass through easily, although more exotic filament might produce even more interesting looking results.

Software

The software for this project is available here.

The software does two things; fade in and out with a speed determined by the constant HEARTBEAT_TIME, and fade between random target colors at a speed determined by the constant TIME_TO_TARGET.

Selecting a new target is done by generating three random numbers, dividing by the sum of those three numbers to normalize it, and then multiplying each number by 1023, the PWM value associated with fully on. This ensures that the three values always add up to (approximately) 1023, meaning the brightness will stay roughly constant.

Fading between colors is done by finding the difference between the current and desired level of each channel, dividing this number by the TIME_TO_TARGET value, and then adding this value to the channel with a small delay after each change, until the target color is reached.

Fading in and out is achieved by subtracting a sine wave from the output value of each channel, with the sine wave's period determined by HEARTBEAT_TIME.

Handling of the PWM itself was abstracted away by the code generated by MPLAB Code Configurator, available here, which made the project much simpler.

Conclusion

Glow Flower

The flower turned out better than I expected, the color fade is subtle enough you don't immediately notice it's happening, and the heartbeat makes it visually interesting and actually further hides the shift in color that's happening. In the future I might try brighter LEDs, although it worked fine under the lights at my house, the fluorescent lights at my work washed out the light a good deal, so I had to put it under something else so the light was still nicely visible.