Digital I/O with Arduino Boards + Diffuser
For this lab:
We were asked to control the output of three LED lights using the Arduino board and a manual input, such as with a keyboard control. Also, to build a diffuser to cover the LEDs.
Materials:
3 LEDs
3 220K Resistors
Arduino, Breadboard, Wires
Poster, Glue (for the Diffuser)
Description
Design a diffuser for your RGB LEDs
The idea is to be able to change the color of the LEDs from the console. Consists of two parts. A python code which sends the string while Arduino code which parses the string a lights up the LEDs.
Arduino code
Description
Use Keyboard to control LED color combination.
Components Used
- R,G,B LEDs
- Resistors 220
- Wires
- Diffuser
Arduino Code
/*
* Serial RGB LED - TUI Homework
* ---------------
* Serial commands control the brightness of R,G,B LEDs
*
* Command structure is multiple typing or 'r' 'g' 'b' keys
*/
Description
- Design a diffuser for LEDs
- Play with keyboard input or other to control 3 LEDs (red, green, blue)
Components Used
Diffuser: A muffin cup and a glass bowl.
LEDs: red, green and blue!
220 ohm resistors
Extra Fun
Prayag and I worked together to create a Color Picker GUI which allows a user to select a color from a color palette of RGB values which then gets sent over the serial port to the arduino.
Arduino Code
***********************************
/* Components Used: leds, Arduino board, piece of bridal vail for diffuser */
/* Diffuser is made with bridal vail, in rose shape so that it covers the leds with many layers */
/*The user can command the color red, yellow or blue at first by 'R', 'Y', 'B', and adjust the color by increasing or decreasing rgb value. */
/* to increase red: 'r ' ; green: 'g' ; blue: 'b' */
/* to decrease red: 'x' ; green:'y' ; blue: 'z' */
Diffuser: Tracing paper on inside of a jar.
keyboard command codes color mapping: r=red, b=blue, g=green, y=r+g, t=b+g, p=b+r, a=r+b+g
color codes {r,g,b,y,t,p,a} fade from full power color to 0.
color codes {R,G,Y,T,P,A} fade from 0 to full power.
code:
Description
This lab and HW uses keyboard input to modify the PWM to create different colors with the RGB LEDs. My diffuser isn't a typical diffuser. I took pieces of a Subway straw (which is an opaque white) and put a piece on each LED (see attached picture, it's cooler in real life). This doesn't diffuse the light equally, but rather creates cylinders of colored light.
Components
Breadboard
Arduino Microcontroller
RGB LEDs
Resistors
Subway straw