标题: 51单片机LCD1602驱动代码 视频 仿真 [打印本页]

作者: 闲散子    时间: 2019-3-14 10:24
标题: 51单片机LCD1602驱动代码 视频 仿真
#include "Config.h"        
#include <intrins.h>
sbit RS = P2^0;
sbit RW = P2^1;
sbit E= P2^2;
void LCD1602_delay_10us(unsigned char i)
{
        unsigned char j;
        while(i--)
        for(j=0;j<10; j++)
                ;
}
void LCD1602_delay_1ms(unsigned char i)
{
        unsigned char j;
        while(i--)
                ;
        for(j=0;j<125;j++)
                ;
}
void LCD1602_Write_Cmd(unsigned char cmd)
{
        LCD1602_delay_10us(5);
        E=0;
        RS=0;
        RW=0;
        LCD_PORT=cmd;
        LCD1602_delay_10us(5); //>40us
        E=1;
        LCD1602_delay_1ms(2); //>150us
        E=0;
        LCD1602_delay_10us(4); //>25+10us?
}
void LCD1602_Write_Dat(unsigned char dat)
{
        LCD1602_delay_10us(5);
        E=0;
        RS=1;
        RW=0;
        LCD_PORT = dat;
        LCD1602_delay_10us(5);
        E=1;
        LCD1602_delay_10us(5);
        E=0;
        LCD1602_delay_10us(4);
}
void LCD1602_Addr_x_y(unsigned char x,bit y)
{
        unsigned char temp=0x80;
        if(y)
        {
                temp|=0x40;
        }
        temp|=x;
        LCD1602_Write_Cmd(temp);
}
void LCD1602_Show_Char(unsigned char x,bit y,unsigned char p)
{
        LCD1602_Addr_x_y(x,y);
        LCD1602_Write_Dat(p);
}
void LCD1602_Show_String(unsigned char x,bit y,char *ptr,unsigned char data_len)
{
        unsigned char i;
        for (i=0;i<data_len;i++)
                {
                LCD1602_Show_Char(x++,y,*(ptr+i));
                }
}
void LCD1602_Init(void)
{
        LCD1602_delay_1ms(1500);
        LCD1602_Write_Cmd(0x38);
        LCD1602_delay_1ms(5);
        LCD1602_Write_Cmd(0x38);
        LCD1602_delay_1ms(5);
        LCD1602_Write_Cmd(0x38);
        LCD1602_delay_1ms(5);
        LCD1602_Write_Cmd(0x38);
        LCD1602_Write_Cmd(0x08);
        LCD1602_Write_Cmd(0x06);
        LCD1602_Write_Cmd(0x0c);
        LCD1602_Write_Cmd(0x01);
}
实录视频连接
链接:https://pan.baidu.com/s/1c1lEja-Kx6IEvJIS74ZpPQ
提取码:m66j
复制这段内容后打开百度网盘手机App,操作更方便哦

1602.jpg (152.96 KB, 下载次数: 114)

仿真电路图

仿真电路图

作者: 榆林上校    时间: 2019-4-18 20:21
好资料,收藏了,
作者: 李家昭    时间: 2019-4-19 15:01
好资料,大佬
作者: 5796619    时间: 2019-4-24 23:04
这是输出什么的




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1