You are on page 1of 5

sbit

sbit
sbit
sbit
sbit
sbit
sbit
sbit
sbit
sbit
sbit
sbit

LCD_RS at RB2_bit;
LCD_EN at RB3_bit;
LCD_D4 at RB4_bit;
LCD_D5 at RB5_bit;
LCD_D6 at RB6_bit;
LCD_D7 at RB7_bit;
LCD_RS_Direction at
LCD_EN_Direction at
LCD_D4_Direction at
LCD_D5_Direction at
LCD_D6_Direction at
LCD_D7_Direction at

TRISB2_bit;
TRISB3_bit;
TRISB4_bit;
TRISB5_bit;
TRISB6_bit;
TRISB7_bit;

//unsigned int kp;


unsigned char state;
void main()
{
TRISA = 0xFF;
adcon1=0b00000110;
CMCON=7;
Lcd_Init();
UART1_Init(9600);
Delay_ms(100);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
lcd_out(2,4,"WELLCOME");
lcd_out(3,1,"AT OUR RESTURANT");
delay_ms(3000);
Lcd_Cmd(_LCD_CLEAR);
state = 1;

// Initialize LCD
// Initialize UART module at 9600 bps
// Wait for UART module to stabilize
// Clear display
// Cursor off

// Clear display
//start from state 1

while(1) {

//while ever loop


switch(state)
{

//check the current state

case 1:
lcd_out(2,2,"Press OK to");
lcd_out(3,2,"Choose Menu");
if(PortA.F4==0)
//OK Button
{
delay_ms(10);
Lcd_Cmd(_LCD_CLEAR);
state = 2;
}
break;
case 2:
//lcd_putc("\f");
lcd_out(1,2,"1: Food");
lcd_out(2,2,"2: Refreshment");
lcd_out(3,2,"3: Miscellaneous");
lcd_out(4,2,"4: Others");
if (PortA.F0==0)
//compare value
{
delay_ms(10);
Lcd_Cmd(_LCD_CLEAR);
state = 3;
//goto another control statement

}
if (PortA.F1==0)
{
Lcd_Cmd(_LCD_CLEAR);
state = 4;
}
if (PortA.F2==0)
{
Lcd_Cmd(_LCD_CLEAR);
state = 5;
}
if (PortA.F3==0)
{
Lcd_Cmd(_LCD_CLEAR);
state = 6;
}
if (PortA.F5==0)
{
Lcd_Cmd(_LCD_CLEAR);
state = 1;
}
break;

//Return button

case 3:
lcd_out(1,3,"FOOD MENU");
lcd_out(2,2,"1: Ndizi");
lcd_out(3,2,"2: Wali");
lcd_out(4,2,"3: Ugali");
if (PortA.F0==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("NDIZI");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F1==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("WALI");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F2==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("UGALI");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F3==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("PILAU");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F5==0)
//return Button.
{
Lcd_Cmd(_LCD_CLEAR);

state = 2;
}
break;
case 4:
lcd_out(1,2,"REFRESHMENTS");
lcd_out(2,2,"1: Tea");
lcd_out(3,2,"2: Juice");
lcd_out(4,2,"3: Breverage");
if (PortA.F0==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("TEA");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F1==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("JUICE");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F2==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("BIA");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F3==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("Whisk");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F5==0)
//Return Button.
Lcd_Cmd(_LCD_CLEAR);
state = 2;
break;
case 5:
lcd_out(1,2,"MISCELLANEOUS");
lcd_out(2,2,"1: Chips");
lcd_out(3,2,"2: Chicken");
lcd_out(4,2,"3: Eggs");
if (PortA.F0==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("CHIPS");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F1==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("CHICKEN");
UART1_Write(10);
UART1_Write(13);

}
if (PortA.F2==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("EGGS");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F3==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("MISHKAKI");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F5==0)
//Return Button.
{
Lcd_Cmd(_LCD_CLEAR);
state = 2;
}
break;
case 6:
lcd_out(1,5,"OTHERS");
lcd_out(2,2,"1: News Papers");
lcd_out(3,2,"2: Coffee");
lcd_out(4,2,"3: Chapati");
if (PortA.F0==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("News Paper");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F1==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("COFFEE");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F2==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("CHAPATI");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F3==0)
{
UART1_Write_Text("New Request table-A");
UART1_Write_Text("MANDAZI");
UART1_Write(10);
UART1_Write(13);
}
if (PortA.F5==0)
//Return Button.
{
Lcd_Cmd(_LCD_CLEAR);
state = 2;
}

break;
}}}

You might also like