搜索
您的当前位置:首页正文

1602显示字符

2020-03-19 来源:步旅网
#include

typedef unsigned int u16; typedef unsigned char u8;

#define DATA P0 sbit rs=P2^2; sbit rw=P2^3; sbit en=P2^4;

void delay(u16 num) { u16 x,y; for(x=num;x>0;x--) for(y=110;y>0;y--); }

void write_cmd(u8 cmd) { rs=0; rw=0; DATA=cmd; delay(5); en=1; delay(5); en=0; }

void write_data(u8 dat) { rs=1; rw=0; DATA=dat; delay(5); en=1; delay(5); en=0; }

void lcd_init(void) { write_cmd(0x02); write_cmd(0x06); write_cmd(0x0c); write_cmd(0x38); write_cmd(0x01); }

int main(void)

//归位设置输入方式控制显示开关功能设置清屏

{ rw=0; rs=0; en=0; lcd_init();

/*write_cmd(0x80); write_data('1'); write_data('2'); write_data('3'); write_data('4'); write_data('5'); write_data('6'); write_data('7'); write_data('8'); write_data('1'); write_data('2'); write_data('3'); write_data('4'); write_data('5'); write_data('6'); write_data('7'); write_data('8'); while(1); }

*/

因篇幅问题不能全部显示,请点此查看更多更全内容

Top