Posts Tagged ‘C code’

In the long corridors of the hotels, unnecessary electricity is consumed on the lights. Ideally when no one is there the lights should be switched off. As the person passes from one end to the other the corresponding.

circuit diagram for reduced power of coridoor light

circuit diagram for reduced power of coridoor light

Figure 6.8 Circuit diagram of the system for auto switching of lights in the corridor

lights should be switched on so that he or she will be guided toward the corridor end. This problem is solved by using arrays of pairs of IR LEDs and phototransistor throughout the corridor placed at equal interval as shown in the block schematic. The array of IR LEDs are in a continuous emitting mode. The corresponding IR phototransistors are aligned at 45◦ for maximizing sensitivity. Value of the resistance (1MΩ to 470Ω) connected to the collector of the phototransistor decides its sensitivity. When the IR link breaks due to the person passing the corridor, a low to high going transition is detected by the port 0 lines. The corresponding bulbs connected to port 1 are made ON and OFF so as to light the corridor as the person makes his way to the other end.

*********************************************************

Program Source Code

mail:billal.0709018@gmail.com

cell:+8801816166360
*********************************************************

#include <REG52.H> /∗ special function register declarations ∗/
#include <stdio.h>
/∗ for the intended 8051 derivative ∗/
sbit sensor1= P0∧0; /∗ Output from the 8 sensors is connected to
the port pins of the port 0 ∗/
sbit sensor2= P0∧1;
sbit sensor3= P0∧2;
sbit sensor4= P0∧3;

sbit sensor5= P0∧4;
sbit sensor6= P0∧5;
sbit sensor7= P0∧6;
sbit sensor8= P0∧7;
/∗ Connecting the relays to on/off the power to the port 1 ∗/
sbit RL1= P1∧0;
sbit RL2= P1∧1;
sbit RL3= P1∧2;
sbit RL4= P1∧3;
sbit RL5= P1∧4;
sbit RL6= P1∧5;
sbit RL7= P1∧6;
sbit RL8= P1∧7;
void main (void) // Main function
{P0=0x00;
P1=0x00;
while(1)
{if(sensor1==1) // Sense the first sensor
RL1=1; // If its output is high then switch the relay on
else if (sensor2==1) // otherwise check the second sensor.
{RL1=0; // Off relay 1 and on relay 2
RL2=1;
}
else if (sensor3==1)
{RL3=1;
RL2=0;
}else if (sensor4==1)
{RL4=1;
RL3=0;
}else if (sensor5==1)

{RL5=1;
RL4=0;
}else if (sensor6==1)
{RL6=1;
RL5=0;
}else if (sensor7==1)
{RL7=1;
RL6=0;
}else if (sensor8==1)
{RL8=1;
RL7=0;
}}
}
*********************************************************