Professional Documents
Culture Documents
Assignment:01
01. Color Mixing Lamp.
Code:
// C++ code
//
0
const int blueLEDPin = 10;
void setup()
Serial.begin(9600);
pinMode(redLEDPin, OUTPUT);
pinMode(blueLEDPin, OUTPUT);
pinMode(greenLEDPin, OUTPUT);
}
1
void loop()
{
redSensorValue = analogRead(redSensorPin);
delay(5);
blueSensorValue = analogRead(blueSensorPin);
delay(5);
greenSensorValue = analogRead(greenSensorPin);
delay(5);
redValue = redSensorValue/4;
blueValue = blueSensorValue/4;
greenValue = greenSensorValue/4;
analogWrite(redLEDPin,redValue);
analogWrite(blueLEDPin,blueValue);
analogWrite(greenLEDPin,greenValue);
Serial.print(redValue);
2
Serial.println(blueValue);
Serial.print(greenValue);
Summary :
RGB LEDs have three internal LEDs (Red, Green, and Blue) that can be
combined to produce almost any color output. In order to produce
different kinds of colors, we need to set the intensity of each internal
LED and combine the three color outputs.
An RGB LED is basically an LED package that can produce almost any
color. It can be used in different applications such as outdoor decoration
lighting, stage lighting designs, home decoration lighting, LED matrix
display, and many more.