標(biāo)題: 51單片機(jī)LCD1602驅(qū)動代碼 視頻 仿真 [打印本頁]

作者: 閑散子    時(shí)間: 2019-3-14 10:24
標(biāo)題: 51單片機(jī)LCD1602驅(qū)動代碼 視頻 仿真
#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);
}
實(shí)錄視頻連接
鏈接:https://pan.baidu.com/s/1c1lEja-Kx6IEvJIS74ZpPQ
提取碼:m66j
復(fù)制這段內(nèi)容后打開百度網(wǎng)盤手機(jī)App,操作更方便哦

1602.jpg (152.96 KB, 下載次數(shù): 114)

仿真電路圖

仿真電路圖

作者: 榆林上校    時(shí)間: 2019-4-18 20:21
好資料,收藏了,
作者: 李家昭    時(shí)間: 2019-4-19 15:01
好資料,大佬
作者: 5796619    時(shí)間: 2019-4-24 23:04
這是輸出什么的




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1