Sunday, 25 January 2015

#WEEK 1 :SIMPLE PROJECT ON HOW TO MAKE A AUTOMATIC EVENING LAMP WITH ARDUINO FOR YOUR HOUSE


Total cost and Materials

 LDR                               -  35 Rs max.
An Arduino UNO           -  1300 Rs.
(or)
An Arduino clone           - 500 Min and 900 Max.
1Amp 5v input relay               -50 MAX.
230 v lamp                       - Depends on type of lamp you use.

Total Min cost :Rs 585

Working

Aim

To make a lamp which can detect the external light and turn off automatically and turns on when there is no external light.

Diagram




Program

boolean flag;  //CHECKS WHETHER THE LIGHT IS ON OR OFF.
void setup()
{
  pinMode(8,OUTPUT);  // connected to the Trigger of the Relay
  pinMode(A0,INPUT);  //To read the sensor Readings
  Serial.begin(9600); //Start serial monitor to troubleshoot during the project
}
void loop()
{
  int sensorinput;
  sensorinput=analogRead(A0); //Reads the value of the sensor
  Serial.println(sensorinput);
  
  // NOW CHECK THE READING OF THE SENSOR BY EXPOSING IT TO BRIGHT LIGHT AND DARK ATMOSPHERE
  // TO KNOW THE THRESHOLD VALUE OF THE LIGHT FOR EXAMPLE WHEN THE SENSOR RECEIVES A BRIGHT LIGHT IT GIVES A MAX VALUE ASSUME IT TO BE 500 AND IN DARK CONDITIONS IT GIVES 0.AS THE LIGHT GETS DIMMER TO THE SENSOR THE READINGS DECREASE FROM 500
  // CHECK THE MAX VALUE OF THE SENSOR AND MAKE A TRIAL AND ERROR AND FIND THE THRESHOLD FOR WHICH THE LAMP HAS TO TURN ON .
  // I HAVE TAKEN 200 FOR THE POST
  
  int threshold=200;
  if(sensorinput<threshold)         //LESS ENVIRONMENT LIGHT
  {
    Serial.println("LIGHTS ON");
    flag=true;
    pinMode(8,HIGH);
  }
  else
  {
    Serial.println("LIGHTS OFF");
    flag=false;
    pinMode(8,LOW);
  }
}

WORKING

In order to understand this project you need to know what is a Relay.

What is a relay?  (FROM http://www.circuitstoday.com/working-of-relays)

We know that most of the high end industrial application devices have relays for their effective working. Relays are simple switches which are operated both electrically and mechanically. Relays consist of a n electromagnet and also a set of contacts. The switching mechanism is carried out with the help of the electromagnet. There are also other operating principles for its working. But they differ according to their applications. Most of the devices have the application of relays.

Why is a relay used?

The main operation of a relay comes in places where only a low-power signal can be used to control a circuit. It is also used in places where only one signal can be used to control a lot of circuits. The application of relays started during the invention of telephones. They played an important role in switching calls in telephone exchanges. They were also used in long distance telegraphy. They were used to switch the signal coming from one source to another destination. After the invention of computers they were also used to perform Boolean and other logical operations. The high end applications of relays require high power to be driven by electric motors and so on. Such relays are called contacts.
Relay generally has 5 terminals . NORMALLY CLOSED,NORMALLY OPEN,COMMON,GROUND,TRIGGER.
IN THE ABOVE DIAGRAM LIVE WIRE OF THE SOCKET IS CONNECTED TO A LAMP AND THE NEUTRAL CONNECTION OF THE LAMP COMES FROM THE Relay's NORMALLY OPEN.WHEN A TRIGGER OF 5V IS SUPPLIED TO THE COIL OF THE RELAY (SAY SENSOR RETURNS A VALUE LESS THAN 200 ).THE COIL MAGNETISES AND THE COMMON GETS CONNECTED TO NORMALLY OPEN INTERNALLY. NOW THE LAMP HAS A CLOSED CIRCUIT AND LIGHT GLOWS AGAIN WHEN THERE IS A HIGH RESPONSE FROM THE SENSOR AND PIN 8 ON ARDUINO GOES LOW  AND THE COIL OF THE RELAY DE-MAGNETISES AND THE CIRCUIT FOR THE LAMP IS BROKEN  AND HENCE THE LIGHT GOES OFF.
LOGIC

SENSOR STATE
ARDUINO DIGITAL PIN STATE
RELAY STATE
LIGHT STATE
threshold> 200
Else part executes
Digital pin goes LOW
Breaks the lamp’s circuit
OFF
<200
If part executes digital pin goes HIGH
Closes the lamp’s circuit
ON


No comments:

Post a Comment