Wednesday, 22 March 2017

WELCOME HOME LCD DISPLAY TO GUEST WITH BUZZER

DEC5052 EMBEDDED SYSTEM APPLICATIONS

Group members:
  • Muhamad Syahir Faris bin Shahrudin (01DIS15F1015)
  • Mohamad Ismat bin Idrussaidi (01DIS15F1012)
  • Muhammad Faris bin Halim (01DIS15F1021)
  • Muhammad Qaiyum bin Arifin (01DIS15F1008)
Class: EMSA

Synopsis

This circuit will ring the house when guest or visitor press the button.


List of hardware/components:

1. LCD Display
2. Buzzer
3. PIC Microcontroller (PIC16F877A)
4. Microcontroller board
5. Switch
6. Wire

List of software:

1. MPLAB IDE v8.91
2. Proteus 8 Professional

Circuit diagram (using Proteus)



Coding


#include<htc.h>

//-------------- CONFIGURATION ----------------------------------------
__CONFIG (0x3F3A);
//-------------- DEFINE THE I/O PIN ------------------------------------
#define RS RA2 //RS pin of the LCD display
#define E RA3 //E pin of the LCD display
#define lcd_data PORTD
#define     d0 RD0
#define     d1 RD1
#define     d2 RD2
#define     d3 RD3
#define     d4 RD4
#define     d5 RD5
#define     d6 RD6
#define     d7 RD7
#define buzzer  RC1
#define SW1 RB0
//-------------- DEFINE VARIABLE DEFINITION --------------------------
//-------------- FUNCTION PROTOTYPE ----------------------------------
void delay(unsigned long a);
void e_pulse(void);
void lcd_clr(void);
void lcd_goto(unsigned char data);
void send_char(unsigned char data);
void send_config(unsigned char data);
void send_string(const char *s);
//-------------- MAIN FUNCTION (WRITE YOUR PROGRAM HERE) --------------
void main()
{                //set I/O input output
TRISA=0b00000000; //Configure PORTA I/O direction
TRISB=0b00000111; //Configure PORTB I/O direction
TRISC=0b00000000;
PORTC=0b00000000;
TRISD=0b00000000;
TRISE=0b00000000;
PORTA=0;
PORTB=0;
PORTC=0;
PORTD=0;
PORTE=0;
//Configure PORTD I/O direction
//setup ADC
ADCON1=0b00000110;
//set RA2, RA3 as digital and rest remain as analog I/O.
//Ensure pin share with analog is being configured to digital correctly
//Configure the LCD
send_config(0b00000001); //clear the LCD.
send_config(0b00000010); //Return cursor to home.
send_config(0b00000110); //Entry mode, cursor increase 1.
send_config(0b00001100); //Display on,cursor off and cursor blink off.
send_config(0b00111000); //Function set.
lcd_clr(); //Clear the LCD.
lcd_goto(0); //Put cursor on position 0.
send_string("PRESS BUTTON");
lcd_goto(20); //Put cursor on position 11.
send_string("TO RING");
b_light=1;
while(1)
if(SW1==0)
while(SW1==0);
lcd_clr(); 
lcd_goto(0);
send_string("WELCOME TO"); 
lcd_goto(20);
send_string("OUR HOUSE");
buzzer = 1;
delay(90000);
}
else
{  
lcd_clr(); 
lcd_goto(0);
send_string("PRESS BUTTON"); 
lcd_goto(22);
send_string("TO RING");
buzzer = 0;
delay(1);
}
}
}
//Delay function. The delay time depends on the given value.
void  delay(unsigned long a)
for(a=0xFF;a!=0;a--) ;
}
void e_pulse(void
{
E=1; 
delay(50); 
E=0; 
delay(50);
} //Send a pulse to the E pin of the LCD.
//Send the configuration to the LCD.
void  send_config(unsigned char data)
unsigned char test; 
unsigned char i;
RS=0;
for(i=0;i<8;i++) .
test=(data>>i)&0b00000001;
switch(i)
case 0:
if(test==1) 
d0=1; 
else d0=0;
case 1:
if(test==1) 
d1=1; 
else d1=0;
case 2:
if(test==1)
d2=1; 
else d2=0;
case 3:
if(test==1) 
d3=1; 
else d3=0;
case 4:
if(test==1) 
d4=1; 
else d4=0;
case 5:
if(test==1) 
d5=1; 
else d5=0;
case 6:
if(test==1) 
d6=1; 
else d6=0;
case 7:
if(test==1) 
d7=1;
else d7=0;
}
delay(50); 
e_pulse(); 
}
//Clear the LCD
void lcd_clr(void)
send_config(0x01); 
delay(600);
}
//Set the location of the LCD cursor.
//If the given value is (0-15)  the cursor will be at the upper line.
//If the given value is (20-35)  the cursor will be at the lower line.
//Location of the lcd cursor (2x16):
// ----------------------------------------------------------
//  ||00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|| 
// ||20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35||
void lcd_goto(unsigned char data)
if(data<16) 
{
send_config(0x80+data);
}
else 
data=data-20 ; 
send_config(0xC0+data);
delay(200);
}
//Send a character to the LCD. 
void send_char(unsigned char data)
unsigned char test; 
unsigned char i;
RS=1;
//Set RS for data mode.
for(i=0;i<8;i++) //Loop for 8 times.
test=(data>>i)&0b00000001;
switch(i)
{
case 0:
if(test==1) 
d0=1; 
else 
d0=0;
case 1:
if(test==1) 
d1=1;
else 
d1=0;
case 2:
if(test==1) 
d2=1; 
else 
d2=0;
case 3:
if(test==1) 
d3=1; 
else 
d3=0;
case 4:
if(test==1) 
d4=1; 
else 
d4=0;
case 5:
if(test==1) 
d5=1; 
else 
d5=0;
case 6:
if(test==1) 
d6=1; 
else 
d6=0;
case 7:
if(test==1) 
d7=1;
else 
d7=0;
}
delay(50); 
e_pulse();
}

//Send a string to the LCD.
void send_string(const char *s)
unsigned char i=0; 
while(s&&*s) 
send_char(*s++); 
delay(1000);
}

Video








Conclusion

This project can make the guest to know what to do when come to the house. This project also enable us to gain experience in electronic circuit and designing. However, a lot of difficulties were encountered in the process of realizing the project work like putting the components correctly in the board and detecting some errors.


No comments:

Post a Comment