• 大小: 40KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-07
  • 语言: 其他
  • 标签: #include  

资源简介

#include #include #define RS_0 PORTD &= ~(1 << PD3) #define RS_1 PORTD |= (1 << PD3) #define RW_0 PORTD &= ~(1 << PD4) #define RW_1 PORTD |= (1 << PD4) #define EN_0 PORTD &= ~(1 << PD6) #define EN_1 PORTD |= (1 <1); } //毫秒级延时程序晶振8MHZ void delay_ms(unsigned int time) { while(time!=0) { delay_us(1000); time--; } } /*显示屏命令写入函数*/ void LCD_write_com(unsigned char com) { RS_0; RW_0; PORTB = com; EN_1; delay_us(20); EN_0; } /*显示屏命令写入函数*/ void LCD_write_data(unsigned char data) { RS_1; RW_0; PORTB = data; EN_1; delay_us(200); EN_0; } /*显示屏清空显示*/ void LCD_clear(void) { LCD_write_com(0x01); delay_ms(5); } /*显示屏字符串写入函数*/ void LCD_write_str(unsigned char x,unsigned char y,unsigned char *s) { if (y == 0) { LCD_write_com(0x80 + x); } else { LCD_write_com(0xC0 + x); } while (*s) { LCD_write_data( *s); s ++; } } /*显示屏单字符写入函数*/ void LCD_write_char(unsigned char x,unsigned char y,unsigned char data) { if (y == 0) { LCD_write_com(0x80 + x); } else { LCD_write_com(0xC0 + x); } LCD_write_data( data); } /*显示屏初始化函数*/ void LCD_init(void) { DDRB = 0xFF; /*I/O口方向设置*/ DDRD |= (1 << PD3) | (1 << PD4) | (1 << PD6); LCD_write_com(0x38); /*显示模式设置*/ delay_ms(5); LCD_write_com(0x38); delay_ms(5); LCD_write_com(0x38); delay_ms(5); LCD_write_com(0x38); LCD_write_com(0x08); /*显示关闭*/ LCD_write_com(0x01); /*显示清屏*/ LCD_write_com(0x06); /*显示光标移动设置*/ delay_ms(5);

资源截图

代码片段和文件信息

评论

共有 条评论

相关资源