欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
LCD1602在51單片機中的簡單程序應用
[打印本頁]
作者:
啊哈小明1234
時間:
2017-5-20 00:56
標題:
LCD1602在51單片機中的簡單程序應用
/**
LCD1602基本顯示 12345
**/
#include <reg52.h>
/**/
typedef unsigned char uchar;
typedef unsigned int uint;
sbit EN = P3^4;//使能信號
sbit RS = P3^5;//數據/命令選擇端
sbit RW = P3^6;//讀/寫選擇端
//判斷液晶忙,如果忙則等待
void Read_Busy()
{
uchar busy;
P0 = 0xff;//復位P0
RS = 0;
RW = 1;
do
{
EN = 1;// RS = 0; RW = 1;EN = 1;讀狀態,輸出P0=D0~D7狀態字
busy = P0;//P0是啥?busy=0x80才跳出來
EN = 0;
}while(busy & 0x80);
}
//寫LCD1602命令一個字節
void Write_Cmd(uchar cmd)
{
Read_Busy();//判斷忙
RS = 0;
RW = 0;
P0 = cmd;//cmd是變量
EN = 1;//這是高脈沖?**寫指令無輸出
EN = 0;
}
//寫一個字節數據
void Write_Dat(uchar dat)
{
Read_Busy();
RS = 1;
RW = 0;
P0 = dat;
EN = 1; //寫數據,高脈沖。。。D0~D7=P0
EN = 0;
}
void main()
{
Write_Cmd(0x38);//設置16*2顯示
Write_Cmd(0x0f);//開顯示 顯示光標,光標閃爍
Write_Cmd(0x01);//清屏
Write_Cmd(0x06);//地址指針移位命令
Write_Cmd(0x80 | 0x06);//顯示地址
//80H按位與地址碼,這里是從第六位之后顯示
Write_Dat(1 + '0');
Write_Dat(2 + '0');
Write_Dat(3 + '0');
Write_Dat(4 + '0');
Write_Dat(5 + '0');
while(1);
}
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1