Site icon Circuit Ideas for You

RGB LED Color Control Circuit with LDR and Arduino

Do anyone like lamps that change color with magic?

This project for RGB LED Color Control Circuit with LDR and Arduino makes its real.

Using RGB LED and three LDR light sensors, we can create a smart lamp that mix colors based on light around it.

Just a simple circuit and with some code, we can get endless color fun.

This circuit is perfect for beginners and hobby makers.

Circuit Coding:

int redPin = 9;
int greenPin = 10;
int bluePin = 11;
int ldrR = A0;
int ldrG = A1;
int ldrB = A2;

void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}

void loop() {
int valR = analogRead(ldrR);
int valG = analogRead(ldrG);
int valB = analogRead(ldrB);

int pwmR = map(valR, 0, 1023, 0, 255);
int pwmG = map(valG, 0, 1023, 0, 255);
int pwmB = map(valB, 0, 1023, 0, 255);

analogWrite(redPin, pwmR);
analogWrite(greenPin, pwmG);
analogWrite(bluePin, pwmB);

delay(50);
}

Coding Explanation:

Circuit Working:

Parts List:

ComponentQuantity
Resistors
220Ω 1/4 watt3
1k 1/4 watt3
Semiconductors
Arduino UNO1
LDR3
RGB LED (Red, Green and Blue)1

This is simple Arduino color mixing lamp circuit.

It can make room corner look nice

Lamp change color when light change in room.

It work automatic and switch color by light condition.

LDR resistance is low when light fall.

LDR resistance is high when its dark.

Arduino read voltage at analog pins A0, A1 and A2.

Arduino change PWM output at pins 9 ,10 and 11.

PWM control LED brightness.

Red, Green, Blue brightness mix to make different colors.

So color of lamp change with light on LDR.

How to Build:

To build a RGB LED Color Control Circuit with LDR and Arduino follow the below steps for connections:

Conclusion:

This RGB LED Color Control Circuit with LDR and Arduino is very simple and very fun project.

RGB LED change color with light sensor.

It is good to learn Arduino, PWM, LDR and RGB mix.

We can use this circuit for smart lamp or room decoration.

References:

An Arduino-Based Experimental Setup for Teaching Light Color Mixing, Light Intensity Detection, and Ambient Temperature Sensing

Exit mobile version