You are on page 1of 4

Project 4

Assignment:01
01. Color Mixing Lamp.

 Circuit 1 (Color Mixing Lamp):

 Code:

// C++ code
//

const int redLEDPin = 11;

0
const int blueLEDPin = 10;

const int greenLEDPin = 9;

const int redSensorPin = A0;

const int blueSensorPin = A1;

const int greenSensorPin = A2;

int redValue =0;

int blueValue =0;

int greenValue =0;

int redSensorValue =0;

int blueSensorValue =0;

int greenSensorValue =0;

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("Mapped SensorValues Red: ");

Serial.print(redValue);

Serial.print(" Blue: ");

2
Serial.println(blueValue);

Serial.print(" Green: ");

Serial.print(greenValue);

 Summary :

In this project we can create custom color combinations at the same


time when we turn on different led lights.In this project you will be
mixing colored light together using an RGB (red-green-blue) LED.

Red + Blue = Violet


Red +Green =Yellow

Green +Blue = Turquoise

Red + Blue + Green = White

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.

You might also like