Introduction: Automatic Switching of Light Using IR Proximity Sensor

This is one of the most simple method to turn on and off light of a room . The method uses two proximity sensor attached to the door which acts a s a counter whether a person has entered a room or not . The Arduino is connected to a relay module which acts as a switch to turn on and off the lights.

Step 1: Hardware

THINGS REQUIRED :

1. Arduino

2. Relay Module for arduino (The number of channels depends on the number of bulbs you want to control)

http://www.ebay.in/itm/1-Channel-Relay-Board-Modul...

3. Bulb

4. Proximity sensor

5. Transformer 230V/9V

6. Power source for Arduino

7.Jumper Wires

Step 2: INTERFACING PROXIMITY SENSOR

1. Proximity Sensor :

A proximity sensor is a sensor able to detect the presence of nearby objects without any physical contact.

A proximity sensor often emits an electromagnetic field or a beam of electromagnetic radiation(infrared, for instance), and looks for changes in the field or return signal. The object being sensed is often referred to as the proximity sensor's target. Different proximity sensor targets demand different sensors. For example, a capacitive or photoelectric sensor might be suitable for a plastic target; an inductive proximity sensor always requires a metal target.

The proximity sensor module contains a IR LED and a photo transistor whose output is given to an operational amplifier IC like LM358 for proper amplification.

The diagram above shows interfacing of a proximity sensor the V pin is connected to the 5V and the GND pin is connected to corresponding GND of the Arduino. The blue box with the screw is used for the sensitivity adjustments. The OUT is connected to the analog input of Arduino.

Two proximity sensors are mounted just below the handle of the door so that when a person opens the door using the handle the proximity sensor shows a change in its output level . The front side of the proximity sensor acts as a positive counter and the one in the back side acts as a negative counter which counts how many person have entered and left .

Step 3: INTERFACING THE RELAY MODULE

Relay Module :

A relay is an electrically operated switch.

Relay breakout module is a smart choice for controlling higher current loads from your microcontroller development board, PC parallel port or Arduino.

The relays are driven by popular darlington array ULN2803A . This darlington transistor provide sufficient output to be driven by the arduino digital output.

Connect the V pin to 5V and the GND pin to the corresponding GND of the Arduino. The darlington IC pins are marked 1-n (n here is the number of relay the darlington IC is driving) connect them to the digital output pins of arduino. the pins marked IN1,IN2....IN8 are used for driving the corresponding relay ,connect these to the digital output pins of the arduino.

The relay have three terminals N/O(NORMALLY OPEN) , N/C(NORMALLY CLOSED), COM.One of the AC terminals which is conventionally connected to a manual switch is connected to the COM terminal and the other is connected to the N/O terminal.

Step 4: SOFTWARE

Callibratting the Proximity Sensor

After interfacing the proximity sensor with Arduino board upload the callibrate program.

Determine the threshold at which the arduino must switch on the light

The serial monitor will show the reading Front for the proximity sensor of the front side of the door and the back will show the reading of the proximity sensor of the backside of the door.

Uploading the Final Program

The the counter will count the no of persons entered.

For Example:

Initially both the counters are 0 and 0.When person enters the proximity sensor 1 says a person enters so counter is increased to 1.Light is on again say again a person enters proximity sensor 1 says a person enters counter is further increased to counter=counter+1 i.e 2.

Now lets say the first person leaves then proximity sensor 2 will exceed threshold and counter is decremented to counter=counter-1 i.e 1.However counter is not equal to zero hence the light is still on.After finally the second person also leaves counter is 0 hence light goes off