直接贴代码很难吗?
试试下面的代码吧,Proteus 仿真成功
- #include<reg52.h>
- #define uint unsigned int
- #define uchar unsigned char
- sbit E = P2^5;
- sbit RW = P2^6;
- sbit RS = P2^7;
- unsigned char send[]={"987654321 "};
- unsigned char send2[]={"There is lkc8210"};
- void delay_ms(int ms)
- {
- int i,j;
- for(i=0; i<ms; i++)
- for(j=0; j<111; j++);
- }
- void delay_us(int us)
- {
- while(--us);
- }
- void Port_W(char value)
- {
- E=0;
- RW=0;
- P0=value;
- E=1;
- delay_us(3);
- E=0;
- }
- void disp(char addr, char dat)
- {
- RS=0;
- Port_W(addr+0x80);
- delay_us(3);
- RS=1;
- Port_W(dat);
- delay_us(3);
- }
- void LCD_Initial()
- {
- RS=0;
- Port_W(0x38);
- Port_W(0x01);
- delay_ms(5);
- Port_W(0x0C);
- }
- void main()
- {
- unsigned char i;
- LCD_Initial();
- delay_ms(1000);
- for(i=0;i<16;i++)disp(i,send[i]);
- for(i=0;i<16;i++)disp(i+0x40,send2[i]);
- while(1)
- {
- }
- }
复制代码
如果还是不显示就是硬件问题
|