LCD1602显示单个字符,内含程序和仿真
单片机源程序如下:
- #include<reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- uint i,j;
- sbit rs=P3^5;
- sbit wr=P3^6;
- sbit lcden=P3^4;
- uchar code table1[]="Frequency:";
- uchar code table2[]="1KHz";
- void delay(uint x)
- {
- for(i=x;i>0;i--)
- {
- for(j=120;j>0;j--);
- }
- }
- void write_com(uchar com)
- {
- rs=0;
- wr=0;
- lcden=0;
- P0=dat;
- lcden=1;
- delay(5);
- lcden=0;
- }
- void init()
- {
- write_com(0x38);
- write_com(0x08);
- write_com(0x01);
- write_com(0x0f);
- }
- void main()
- {
- init();
- while(1);
- }
复制代码
所有资料51hei提供下载:
lcd1602.zip
(13.75 KB, 下载次数: 7)
|