Project tutorial
Control your light with Arduino

Control your light with Arduino © GPL3+

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

  • 2,416 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

Created by

GiorgioTraverso

Are you GiorgioTraverso? Claim this project and add it to your profile.

This is mine

Posted by

Arduino scuola
Arduino_Scuola
  • 32 projects
  • 98 followers

Published on

July 8, 2016

Members who respect this project

Avatar fofgrbxpczDefault

and 2 others

See similar projects
you might like

Similar projects you might like

Control your light system with your voice

Project tutorial by Maha Raafat

  • 33,112 views
  • 22 comments
  • 147 respects

WIZnet S2E Light Control

Project tutorial by Team S2ELighting

  • 1,448 views
  • 0 comments
  • 7 respects

Control your Light System Using Smart Phone

Project tutorial by Ahmed Yassin

  • 35,260 views
  • 4 comments
  • 55 respects

Light Control Using Arduino and Amazon Alexa

Project tutorial by Rajesh

  • 12,180 views
  • 1 comment
  • 14 respects

How to control your light switch from your smartphone?

Project in progress by Mahmoud Ahmed

  • 22,607 views
  • 3 comments
  • 15 respects

Control an LED with the Remote Control

Project showcase by Nicholas_N

  • 3,192 views
  • 2 comments
  • 9 respects
Add projectSign up / Login