標(biāo)題:
超聲波液晶顯示
[打印本頁]
作者:
田鵬
時(shí)間:
2017-7-2 08:37
標(biāo)題:
超聲波液晶顯示
#include <reg52.H>
#include <intrins.H>
#include <math.H>
#define uchar unsigned char
#define uint unsigned int
sbit dula = P2^6;//數(shù)碼管鎖存器關(guān)閉
sbit wela = P2^7;
sbit RS = P3^5; 顯示屏打開
sbit LCDEN = P3^4;
void delayUs()
{
_nop_();
}
void delayMs(uint a)
{
uint i, j;
for(i = a; i > 0; i--)
for(j = 100; j > 0; j--);
}
void writeComm(uchar comm)
{
RS = 0;
P0 = comm;
LCDEN = 1;
delayUs();
LCDEN = 0;
delayMs(1);
}
//寫數(shù)據(jù):RS=1, RW=0;
void writeData(uchar dat)
{
RS = 1;
P0 = dat;
LCDEN = 1;
delayUs();
LCDEN = 0;
delayMs(1);
}
void init()
{
dula = wela = 0;
writeComm(0x38); //顯示模式
writeComm(0x0c);//光標(biāo)
writeComm(0x06); //光標(biāo)位置,科左移
writeComm(0x01); //清屏
}
void writeString(uchar * str, uchar length)
{
uchar i;
for(i = 0; i < length; i++)
{
writeData(str[i]);
}
}
void main()
{
uchar table[] = " xianzaiwendu:";
init();
writeComm(0x80);
writeString(table, 16);
while(1)
{
}
復(fù)制代碼
作者:
黑泡泡
時(shí)間:
2021-5-18 12:51
程序有問題
作者:
51hei團(tuán)團(tuán)
時(shí)間:
2021-5-18 18:08
黑泡泡 發(fā)表于 2021-5-18 12:51
程序有問題
我在搜索框輸入"超聲波 1602"幫你搜索到了幾個(gè)能成功仿真的工程
http://www.torrancerestoration.com/bbs/dpj-189056-1.html
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1