Yonas Kelem gebreslassie
Created June 28, 2024

Automatic Room Light Controller Using PIC Microcontroller

The Project , 'Automatic Room Light controller' controls a room light as well as count the number of persons entering and leaving a room.

25
Automatic Room Light Controller Using PIC Microcontroller

Things used in this project

Hardware components

Liquid Crystal Display (LCD)
×1
Microcontroller PIC16F877A
×1
um790 mini pc
×1
WunderBar
Relayr WunderBar
×1
PIR Sensor Human Body Infrared PIR Motion Sensor (AS312)
M5Stack PIR Sensor Human Body Infrared PIR Motion Sensor (AS312)
×1

Software apps and online services

MikroC for PIC compiler
ISIS Proteus-8 software
AMD Ryzen software

Story

Read more

Schematics

automatic room light controller using PIC16f877A_microcontroller

this is the detail of the project that i have done

Code

Program Name: AUTOMATIC ROOM LIGHT CONTROLLER USING PIC MICROCONTROLER

C#
the code displays status of room occupancy in a controlled room. Based on the count and status of the infrared sensor output, the lights are switched on and off automatically and the status of the room occupancy is shown on the LCD and also open-close the door.
/*Program Name: AUTOMATIC ROOM LIGHT CONTROLLER USING PIC MICROCONTROLER */
/* Name of Author: Yonas Kelem */

/* MEKELLE UNIVERSITY student */


/*	*/

/* the code displays status of room occupancy in a controlled room. Based on the count and status of the infrared sensor output, the lights are switched on and off automatically and the status of the room occupancy is shown on the LCD and also open-close the door.   */
/*	*/

sbit LCD_D7 at RB2_bit; 
sbit LCD_D6 at RB3_bit; 
sbit LCD_D5 at RB4_bit; 
sbit LCD_D4 at RB5_bit; 
sbit LCD_EN at RB6_bit; 
sbit LCD_RS at RB7_bit;
sbit LCD_D7_Direction at TRISB2_bit; 
sbit LCD_D6_Direction at TRISB3_bit; 
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D4_Direction at TRISB5_bit; 
sbit LCD_EN_Direction at TRISB6_bit; 
sbit LCD_RS_Direction at TRISB7_bit;
 
//************************SENSIN/OUT **************** int x[]={12,6,3,9};
int s1=0,s2=0,count=0,light=0,i,j;
unsigned short int D0,D1,D2; 
void lcd_disp(int y)
{
lcd_out(2,1,"people in="); 
D0=y%10; 
D1=(y/10)%10; 
D2=(y/100);
Lcd_Chr_cp(D2+48); 
Lcd_Chr_cp(D1+48); 
Lcd_Chr_cp(D0+48);
}
void rotation_90()
{
for(i=0;i<50;i++)
{
portd.f6=1; 
delay_us(1500); 
portd.f6=0; 
delay_us(18500);
}
}
void rotation_180()
{
for(i=0;i<50;i++)
{
portd.f6=1; delay_us(220); 
portd.f6=0;
 
delay_us(17800);
}
}
void door_open()
{
delay_ms(200); rotation_90();
}
void door_close()
{
rotation_90(); 
delay_ms(200); 
rotation_180();
}
void main()
{
ADC_Init(); Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); 
Lcd_Cmd(_LCD_CURSOR_OFF); 
lcd_out(1,1,"Automatic RLC");
trisb=0;
trisa=1; 
trisc=1; 
trisd=0;
portd=0; 
portb=0; 
while(1)
{
light=Adc_read(0)/204.6;
door_open();
 
if(portc.f2==1&&s1==0)
{ s1=1;
door_open();
}
if(portc.f2==0&&s1==1)
{ s1=0;
door_close(); 
count=count+1; 
lcd_disp(count);
}
if(portc.f3==1&&s2==0)
{
  s2=1;
if(count==0)
{
count=0;
}
else
{
door_open();
count=count-1;
}
lcd_disp(count);
}
if(portc.f3==0&&s2==1)
{ s2=0;
door_close();
}
 
if(light<=3&&count>0)
{
portd.f7=1;
}
else
{
portd.f7=0;
}
}
}

Credits

Yonas Kelem gebreslassie
1 project • 0 followers

Comments