单片机==lcd_笑脸(24)

#include #include "delay.h"#define LCDPORT P0sbit RS = P2^4;sbit RW = P2^5;sbit E = P2^6;#define LCD_WRITE_DATA 1#define LCD_WRITE_COM 0void lcd_write(unsigned char byte, unsigned char fl
摘要由CSDN通过智能技术生成
#include <reg52.h>
#include "delay.h"

#define LCDPORT P0
sbit RS = P2^4;
sbit RW = P2^5;
sbit E = P2^6;

#define LCD_WRITE_DATA 1
#define LCD_WRITE_COM 0

void lcd_write(unsigned char byte, unsigned char flag)
{
    if(flag)
    {
        RS = 1;
    }
    else
    {
        RS = 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#include <reg52.h> #include <stdio.h> #define LCD1602_RS P2_0 // LCD1602?RS?? #define LCD1602_RW P2_1 // LCD1602?RW?? #define LCD1602_EN P2_2 // LCD1602?EN?? #define LCD1602_DATAPINS P0 // LCD1602????? sbit UART_RXD = P3^0; // ?????? sbit UART_TXD = P3^1; // ?????? void init_uart() // ????? { TMOD |= 0x20; // ?????1???2 TH1 = 0xfd; // ??????9600 TL1 = 0xfd; TR1 = 1; // ?????1 SCON = 0x50; // ???????1 ES = 1; // ?????? EA = 1; // ????? } void init_lcd() // ???LCD { LCD1602_RS = 0; LCD1602_RW = 0; LCD1602_EN = 0; delay_ms(15); lcd_write_cmd(0x38); // ??LCD?16x2????? delay_ms(5); lcd_write_cmd(0x0c); // ??LCD?? delay_ms(5); lcd_clear(); // ?? lcd_write_cmd(0x06); // ???????? } void lcd_write_cmd(unsigned char cmd) // ????LCD { LCD1602_RS = 0; LCD1602_DATAPINS = cmd; LCD1602_EN = 1; delay_us(2); LCD1602_EN = 0; delay_ms(1); } void lcd_write_data(unsigned char dat) // ????LCD { LCD1602_RS = 1; LCD1602_DATAPINS = dat; LCD1602_EN = 1; delay_us(2); LCD1602_EN = 0; delay_ms(1); } void lcd_clear() // ?? { lcd_write_cmd(0x01); } void lcd_set_cursor(unsigned char x, unsigned char y) // ?????? { unsigned char addr; if (y == 0) addr = 0x80 + x; else addr = 0xc0 + x; lcd_write_cmd(addr); } void lcd_puts(unsigned char x, unsigned char y, unsigned char *str) // ?????????? { lcd_set_cursor(x, y); while (*str != '\0') { lcd_write_data(*str); str++; } } void uart_isr() interrupt 4 // ???????? { if (RI) { RI = 0; lcd_write_data(SBUF); // ?????????LCD? } } void main() { init_uart(); init_lcd(); while (1); }
06-08

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值