#include<reg51.h>
sbit en=P2^0;
sbit rs=P2^1;
sbit sw1=P2^2;
sbit sw2=P2^3;
sbit sw=P2^4;
void lcd_cmd(unsigned char cmd);
void ldata(unsigned char value);
void lcd_string(char *str);
void lcd_init();
void delay();
char arr[9]={"low level"},i;
char arr1[12]={"middle level",},i;
char arr2[10]={"high level"},i;
void main()
{
lcd_init(0x01);
if(sw1==0)
{
for(i=0;i<9;i++)
{
ldata(arr[i]);
delay();
}
}
if(sw2==0)
{
for(i=0;i<12;i++)
{
ldata(arr1[i]);
delay();
}
}
if(sw1==0)
{
for(i=0;i<10;i++)
{
ldata(arr2[i]);
delay();
}
}
void lcd_init()
{
lcd_cmd(0x38);
lcd_cmd(0x0e);
lcd_cmd(0x80);
lcd_cmd(0x01);
}
void lcd_cmd(char cmd)
{
P1=cmd;
rs=0;
en=1;
delay();
en=0;
}
void ldata(char value)
{
P1=value;
rs=1;
en=1;
delay();
en=0;
}
void delay()
{
unsigned int j,k ;
for(k=0;k<20;k++)
{
for(j=0;j<1000;j++);
}
}
sbit en=P2^0;
sbit rs=P2^1;
sbit sw1=P2^2;
sbit sw2=P2^3;
sbit sw=P2^4;
void lcd_cmd(unsigned char cmd);
void ldata(unsigned char value);
void lcd_string(char *str);
void lcd_init();
void delay();
char arr[9]={"low level"},i;
char arr1[12]={"middle level",},i;
char arr2[10]={"high level"},i;
void main()
{
lcd_init(0x01);
if(sw1==0)
{
for(i=0;i<9;i++)
{
ldata(arr[i]);
delay();
}
}
if(sw2==0)
{
for(i=0;i<12;i++)
{
ldata(arr1[i]);
delay();
}
}
if(sw1==0)
{
for(i=0;i<10;i++)
{
ldata(arr2[i]);
delay();
}
}
void lcd_init()
{
lcd_cmd(0x38);
lcd_cmd(0x0e);
lcd_cmd(0x80);
lcd_cmd(0x01);
}
void lcd_cmd(char cmd)
{
P1=cmd;
rs=0;
en=1;
delay();
en=0;
}
void ldata(char value)
{
P1=value;
rs=1;
en=1;
delay();
en=0;
}
void delay()
{
unsigned int j,k ;
for(k=0;k<20;k++)
{
for(j=0;j<1000;j++);
}
}