1. Project Report
E 222: MicroProcessor Systems
Group Members:
Taimoor Tahir (4628)
Hassan Saeed (5718)
Hafiz Saad Abdul Majid (5223)
Submitted To: Ma’am Hira Taqdees
Date: 8 June 2015
3. sbit C4 = P0^7;
//End Keypad Connections
//LCD Connections
sbit rs = P2^0; // declare P2.0 as rs pin
sbit en = P2^2; // declare p2.2 as enable pin
sbit rw = P2^1; // declare p2.1 as read/write pin
sbit b = P1^7; // busy flag port 1.7
//End Lcd Connections
//Outputs
sbit enable = P2^4;
sbit motor = P2^3;
//Outputs
float time = 0;
unsigned char count = 0;
unsigned int speed = 4;
unsigned int weight = 0;
float calories = 0;
void busy() // function to check LCD is busy or not
{
en = 0; // disable display
P1 = 0xFF; // configur P1 as input
rs = 0; // clear rs pin for command
rw = 1; // set rw pin to read
4. while(b==1)
{
en=0; // strob LCD till P1.7 is 1
en=1;
}
en=0;
}
void writecmd(unsigned char a) // function to send command to LCD
{
busy(); // check for LCD is busy or not
rs = 0; // clear rs pin for command
rw = 0; // clear rw pin to write
P1 = a; // send command character
en = 1; // strob LCD
en = 0;
}
void writedat(unsigned char b) // function to send data to LCD
{
busy(); // check for LCD is busy or not
rs = 1; // set rs pin for data
rw = 0; // clear rw pin to write
P1 = b; // send data character
en = 1; // strob LCD
en = 0;
}
void writestr(unsigned char *s) // function to write string on LCD
{
5. unsigned char l,i;
l = strlen(s); // get the length of string
for(i=1;i<=l;i++)
{
writedat(*s); // write every char one by one
s++;
}
}
void delay(unsigned int msec) //Function to provide time delay in msec.
{
unsigned int i,j;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
char Read_Keypad()
{
C1=1;
C2=1;
C3=1;
C4=1;
R1=0;
R2=1;
R3=1;
R4=1;
if(C1==0){delay(50);while(C1==0);return '7';}