Domestic Lighting-Temperature and Brightness Control




Introduction to a mini project for automation of your home lighting system using Arduino micro-controller and processing software.Although the LED brightness control is very common among light control systems, light temperature control is not frequently used in many applications.

This mini project can be developed for a much improved version to use domestically or otherwise.
 
The project is done under Extra Low Voltage(ELV) conditions.

 

Tools And Components

1 X Arduino Nano(ATmega328P) Micro-controller Board

1 X SMD LED (2700K - 3000K) - warm

1 X SMD LED (4000K - 6000K) - cool/daylight

1 X Breadboard(400pin)

2 X 220ohm Resistor

Connecting Wires

Arduino IDE

Processing Software


Connecting Components



Connect Components as shown in the figure.Note that you must use SMD LEDs instead of LEDs shown in the diagram.

(4000K - 6000K)SMD LED to Arduino pin D-11
(2700K - 3000K)SMD LED to Arduino pin D-09

In this project ; an emergency lamp with both warm and cold SMD LEDs is used instead of two LEDs.

 

Adding Processing Libraries

For this step internet connection is required.
After executing Processing, Goto Sketch > Import Library > Add Library
New window will open.
In the Libraries tab, search for ControlP5 ; From search result select controlp5 and install it.

 

Arduino Code

#define Brighness 11
#define Temp 10
int val1 = 0;
int range = 0;

void setup() {
pinMode(Brighness, OUTPUT);
analogWrite(Brighness,0);
pinMode(Temp, OUTPUT);
analogWrite(Temp,0);
Serial.begin(9600);
}

void loop() {
  if(Serial.available()){
     val1 = Serial.read();
     int range = map(val1, 102, 255, 0,255);

   if (val1 <= 100) {
     
    analogWrite(Brighness,val1);
    }

    if (val1 == 100) {
     
    analogWrite(Brighness,val1);
    }
   
    if (val1 >= 102) {
    analogWrite(Temp,range);
    }
  }
    if(val1 == 'a'){
      analogWrite(11,val1);
      analogWrite(10,range);
    }

    if(val1 =='d'){
     digitalWrite(11,LOW);
     digitalWrite(10,LOW);
    }
}

 

Processing Code

import controlP5.*;
import processing.serial.*;

Serial port;
ControlP5 cp5;
PFont font;
color currentcolor;

void setup() {
 
 size(1000, 550);
 printArray(Serial.list());

 port = new Serial(this, "COM3", 9600);//Choose correct COM number which is your Arduino board connected to:

 cp5 = new ControlP5(this);
 font = createFont("Calibri", 30);

 cp5.addButton("ON")
    .setPosition(100, 100)
    .setSize(300,70)
    .setFont(font)
    .setColorBackground(color(100, 150, 255))
 ;  
   
  cp5.addButton("OFF")
    .setPosition(600, 100)
    .setSize(300,70)
    .setFont(font)
    .setColorBackground(color(100, 150, 255))

;

  cp5.addSlider("Brightness")
     .setPosition(150, 300)
     .setSize(500,70)
     .setRange(0,100)
     .setValue(0)
     .setFont(font)
     .setColorValue(color(0,0,255))
     .setColorBackground(color(100, 100, 255))
     ;
    
   cp5.addSlider("Temperature")
     .setPosition(150, 400)
     .setSize(500,70)
     .setRange(102,255)
     .setValue(102)
     .setFont(font)
     .setColorValue(color(0,0,255))
     .setColorBackground(color(100, 100, 255))
     ; 
   
}

void draw(){
 background(50, 0 ,100);
 fill(200, 200,255);
 text("LED Control",350, 50);
 textSize(15);
 text("By Chathura.H®",450, 520);
 textSize(50);

}

void ON(){
  port.write('a');
}

void OFF(){
  port.write('d');
}

void Brightness(int Brightness){
  port.write(Brightness);
}

void Temperature(int Temperature){
  port.write(Temperature);
}

NOTE : Keep in mind that COM port may vary according to your Arduino connection settings.

 

Run the Code!

Check everything is set correctly one last time and upload the Arduino sketch into Arduino board.

Then run the Processing sketch.

If everything is connected properly LED Control GUI should be displayed.

Turn ON/OFF system by using ON & OFF Buttons.

Use Brightness slider to control Brightness of the light system

Use Temperature slider to control Temperature of the light system


 

 

Further Development 

Other than Brightness and temperature Control, using multiple color LEDs, full spectrum color temperature can be controlled.

Instead of two SMD LEDs, use SMD LED mesh for better illumination and wide spread lighting system.(To get required power for the mesh, you can use IRF520 MOSFET -external power source required)

Instead of using the code for turn ON/OFF commands, use a relay module to turn ON/OFF the system.This will gain a better control over slider operation.

(This project is designed and tested for its complete operation)

Post a Comment

Previous Post Next Post