Project tutorial
Control your light with Arduino

Control your light with Arduino © GPL3+

This project teaches how create a domotics lamp with your Arduino.

  • 4,199 views
  • 0 comments
  • 4 respects

Components and supplies

Apps and online services

About this project

1. Make the prototype

First: take the necessary parts and create the prototype on your breadboard as you see in the schematic below.

2. Write the code on Arduino

Second: write code! (see code below)

3. Make your box

Third: cut the plexiglass by a Laser Cutter.

After, decide where to collocate the Arduino with the Shield and the power supply, and then make one hole for the potentiometer and one for the lamp's cables. Paste all! Congratulations! You just made a domotic lamp with the Arduino! Good job guys! Implement code to improve the lamps with your ideas (for example add also a timer to regulate it)!

4. Some photos

Some photos of the final project.

Code

Code snippet #1Arduino
//Declaration of the sensor and led
const int sensorPin = A0;
const int ledPin = 3;
const int potentiometerPin = A1;
//Declaration variables
float potentiometerVal;
float sensorVal;//sensor
float light = 0;//brightness led
float mapping;//mapping of led

void setup(){
  // open a serial connection to display values
  Serial.begin(9600);
  //set up the Pin of the Led
  pinMode(ledPin,OUTPUT);
}

void loop(){
  sensorVal = analogRead(sensorPin);
  potentiometerVal = analogRead(potentiometerPin);
  
  //Reverse mapping of the light to the brightness
  potentiometerVal = map(potentiometerVal, 0, 1023, 0, 255);
  sensorVal = map(sensorVal,0,1023, 255, 0);
  mapping = potentiometerVal;
  light = map (sensorVal, 0, 255, sensorVal - potentiometerVal , 255);
  
  if (light <= 0)
    light=0;
    
  Serial.print("Brightness: ");
  Serial.println(sensorVal);
  Serial.print("Mapping: ");
  Serial.println(potentiometerVal);
  analogWrite(ledPin,light);
  Serial.print("Light: ");
  Serial.println(light);
  delay(15);
}

Schematics

Schematic #1
750x750 53497cba9967d8 0muis0vebi

Comments

Similar projects you might like

Control your light system with your voice

Project tutorial by Maha Raafat

  • 42,026 views
  • 22 comments
  • 160 respects

WIZnet S2E Light Control

Project tutorial by Team S2ELighting

  • 2,148 views
  • 0 comments
  • 7 respects

Control your Light System Using Smart Phone

Project tutorial by Ahmed Yassin

  • 46,387 views
  • 6 comments
  • 63 respects

Light Control Using Arduino and Amazon Alexa

Project tutorial by Rajesh

  • 19,599 views
  • 1 comment
  • 20 respects

Control AC Light Using Arduino

by Mayoogh Girish

  • 7,514 views
  • 1 comment
  • 16 respects

How to control your light switch from your smartphone?

Project in progress by Mahmoud Ahmed

  • 24,166 views
  • 3 comments
  • 15 respects
Add projectSign up / Login