Thursday, October 29, 2009
RGB LED Prototype
GOAL:
Controlling the color combination change, exhibited by our RGB LED.
PROCESS:
The circuit is divided into two sections, the Input and Output
sections. The input circuit has three potentiometers, which are simply
variable resistors. For this application, we are using the
potentiometers to produce a controllable analog voltage by connecting
the potentiometer's ends to power and ground, and connecting the third
terminal (the "wiper") to the analog input pin. When we turn the
potentiometer, the measured voltage will vary between ground and power
(here, 5 volts). There are three potentiometers, one for each color,
and are connected to the Arduino's analog inputs 0, 1, and 2,
corresponding to red, green, and blue.
The output circuit has the LED's common anode connected directly to
power (also known as Vdd). The cathode pin of each color is connected
through a current-limiting resistor to one of the digital output pins
on the Arduino. The current-limiting resistors are used to protect the
LEDs from over-current situations, and if you want more information
about driving LEDs with and without resistors, there is a good guide at
the Tinkerlog website.
We use the Arduino's pins 9, 10, and 11 specifically because these pins
are able to do PWM output, via the analogWrite() function. This allows
us to set the brightness for each color independently.
RESULT:
I had light come up, but always blue,
it did follow the cycle, I believe that it skipped showing other two colors,
Circuit seems to be very complicated and it is hard to determine what went wrong,
Another Circuit should be used.
CODE:
// RGB LED - Automatic Color Cycling
//
// Matthew L Beckler
// matthew at mbeckler dot org
int redPin = 11;
int bluePin = 10;
int greenPin = 9;
int redIn = 0;
int greenIn = 1;
int blueIn = 2;
int redVal;
int greenVal;
int blueVal;
void setup()
{
redVal = 255;
greenVal = 255;
blueVal = 255;
update();
}
// This function updates the LED outputs.
void update()
{
analogWrite(redPin, redVal);
analogWrite(greenPin, greenVal);
analogWrite(bluePin, blueVal);
}
// This function updates one of the color variables
// either getting brighter or getting dimmer.
// It also updates the outputs and delays for 10 milliseconds.
void color_morph(int* value, int get_brighter)
{
for (int i = 0; i < 255; i++)
{
if (get_brighter)
(*value)--;
else
(*value)++;
update();
delay(10);
}
}
void loop
{
// start out at black (all off)
color_morph(&redVal, 1); // transition to red
color_morph(&greenVal, 1); // transition to yellow
color_morph(&redVal, 0); // transition to green
color_morph(&blueVal, 1); // transition to aqua
color_morph(&redVal, 1); // transition to white
color_morph(&greenVal, 0); // transition to violet
color_morph(&redVal, 0); // transition to blue
color_morph(&blueVal, 0); // transition to black (all off)
}
SOURCE:
http://www.mbeckler.org/microcontrollers/rgb_led/
team k.a.a.s
UPDATE:
We have got something! - *Look at the video.
Labels: K.A.A.S., Living Architecture, Pratt, Responsive Architecture
Post a Comment