CSIW
Newbie level 5
- Joined
- Jan 6, 2015
- Messages
- 8
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 52
My LCD screen is EB-005-00-3
and here is my code for drink menu:
my problem is when I get into the second menu which is cold drink menu / hot drink menu,
the LCD shows muddle / garbled.
I am so sure that they can run separately but not when I combine them:bang:
Can anyone help me clear my mind that where is the problem in my code?
and here is my code for drink menu:
Code:
#include "LCDdrive.h" //LCD header file
void MainMenu(void);
void ColdMenu(void);
void HotMenu(void);
char themain=1;
char cold=1;
char hot=1;
void main()
{
TRISD=0x9f;
TRISB=0x00;
PORTB=0x00;
PORTD=0x00;
while(1)
{
Mainmenu();
}
}
void MainMenu()
{
LCD_initialise();
while(1)
{
if(themain==1)
{
LCD_cursor(0,0);
LCD_puts(">Cold drinks");
LCD_cursor(0,1);
LCD_puts(" Hot drinks");
}
if(themain==2)
{
LCD_cursor(0,0);
LCD_puts(" Cold drinks");
LCD_cursor(0,1);
LCD_puts(">Hot drinks");
}
if(PORTD.B0==1)
{
themain=1;
}
if(PORTD.B1==1)
{
themain=2;
}
if(PORTD.B2==1&&themain==1)
{
ColdMenu();
}
if(PORTD.B2==1&&themain==2)
{
HotMenu();
}
}
}
void ColdMenu()
{
LCD_initialise();
while(1)
{
if(cold==1)
{
LCD_cursor(0,0);
LCD_puts(">Orange Juice");
LCD_cursor(0,1);
LCD_puts(" Fizzy Drink");
}
if(cold==2)
{
LCD_cursor(0,0);
LCD_puts(" Orange Juice");
LCD_cursor(0,1);
LCD_puts(">Fizzy Drink");
}
if(cold==3)
{
LCD_cursor(0,0);
LCD_puts(" Fizzy Drink ");
LCD_cursor(0,1);
LCD_puts(">Water ");
}
if(PORTD.B0==1)
{
cold=cold-1;
if(cold<1)
{
cold=1;
}
}
if(PORTD.B1==1)
{
cold=cold+1;
if(cold>3)
{
cold=3;
}
}
}
}
void HotMenu()
{
LCD_initialise();
while(1)
{
if(hot==1)
{
LCD_cursor(0,0);
LCD_puts(">Tea ");
LCD_cursor(0,1);
LCD_puts(" Coffee");
}
if(hot==2)
{
LCD_cursor(0,0);
LCD_puts(" Tea ");
LCD_cursor(0,1);
LCD_puts(">Coffee");
}
if(hot==3)
{
LCD_cursor(0,0);
LCD_puts(">chocolate");
LCD_cursor(0,1);
LCD_puts(" soup ");
}
if(hot==4)
{
LCD_cursor(0,0);
LCD_puts(" chocolate");
LCD_cursor(0,1);
LCD_puts(">soup ");
}
if(PORTD.B0==1)
{
hot=hot-1;
if(hot<1)
{
hot=1;
}
}
if(PORTD.B1==1)
{
hot=hot+1;
if(hot>4)
{
hot=4;
}
}
}
}
my problem is when I get into the second menu which is cold drink menu / hot drink menu,
the LCD shows muddle / garbled.
I am so sure that they can run separately but not when I combine them:bang:
Can anyone help me clear my mind that where is the problem in my code?