I used one foam peanut and one plastic can to create the diffuser. I first tried to use the plastic can only to make the diffuser, but realized that the mixed color wasn't well distributed. As a result, I then stabbed all LED lights into a foam peanut before covering them with the plastic can, and found that the color-mixing effect worked better in this way.
For multiple key press section, I set the default brightness to 10 for all red, green and blue lights. When user inputs r, g or b, the brightness of that color increases 45. When the brightness excess 225, the value will be reset to 0. For example, the result of 'rrgggbbbb' will be: brightness of red = 90, brightness of green = 135, brightness of blue = 180.
Components Used:
1 Arduino Uno
3 220 Ohm Resistor
3 LEDs (R, G, B)
1 Plastic Bottle
1 Foam Peanut
Code:
/*
* Serial RGB LED
* ---------------
* Serial commands control the brightness of R,G,B LEDs
*
* Command structure is "<colorCode><colorVal>", where "colorCode" is
* one of "r","g",or "b" and "colorVal" is a number 0 to 255.
* E.g. "r0" turns the red LED off.
* "g127" turns the green LED to half brightness
* "b64" turns the blue LED to 1/4 brightness
*
* Alternate command structure is "<colorCode>*", where "colorCode" is
* one of "r","g", or "b".
* E.g. "r" increases the red LED brightness by 10
* "rrr" increases the red LED brightness by 30
* "ggb" increases the green LED brightness by 20 and the blue by 10