display interface xxx //显示个端口状态,用?可以查看后边跟的选项

display interface xxx //显示个端口状态,用?可以查看后边跟的选项

#include <reg51.h> #define LCD_DB P0 sbit LCD_RS = P2^0; sbit LCD_RW = P2^1; sbit LCD_EN = P2^2; void init_lcd(); void write_command(unsigned char command); void write_data(unsigned char data); void display_string(unsigned char x, unsigned char y, unsigned char *string); void delay(unsigned int i); void main() { unsigned char i; unsigned char data_buffer[16] = "Hello, World!"; init_lcd(); display_string(0, 0, data_buffer); // ????? SCON = 0x50; TMOD = 0x20; TH1 = 0xFD; TL1 = 0xFD; TR1 = 1; while(1) { // ?????????? while(RI == 0); RI = 0; // ?????????????? data_buffer[0] = SBUF; // ?LCD????? display_string(0, 0, data_buffer); } } void init_lcd() { write_command(0x38); // ????:8????,2???,5x7???? write_command(0x0C); // ????:???,???,??? write_command(0x06); // ????:?????,????,????? write_command(0x01); // ????:????,???????? delay(10); // ??10?? } void write_command(unsigned char command) { LCD_RS = 0; LCD_RW = 0; LCD_DB = command; LCD_EN = 1; delay(5); LCD_EN = 0; } void write_data(unsigned char data) { LCD_RS = 1; LCD_RW = 0; LCD_DB = data; LCD_EN = 1; delay(5); LCD_EN = 0; } void display_string(unsigned char x, unsigned char y, unsigned char *string) { unsigned char i; if(x < 16) { if(y == 0) { write_command(0x80 + x); } else if(y == 1) { write_command(0xC0 + x); } else { return; } } else { return; } for(i = 0; string[i] != '\0' && i < 16 - x; i++) { write_data(string[i]); } } void delay(unsigned int i) { unsigned int j, k; for(j = 0; j < i; j++) { for(k = 0; k < 1000; k++); } }
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值