1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉
標題:
基于51單片機和ADC0808的電壓表設計
[打印本頁]
作者:
zgxxgl
時間:
2018-6-16 16:17
標題:
基于51單片機和ADC0808的電壓表設計
信號源參數設置(U2)
(程序)
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbitoe=P2^0;
sbiteoc=P2^1;
sbitst=P2^2;
sbitale=P2^6;
sbitrs=P2^4;
sbitre=P2^5;
uchar tab[]={0,'.',0,0};
uintgetdata;
voiddelay(uint x)
{ uint a,b;
for(a=x;a>0;a--)
for(b=110;b>0;b--); }
void wzhiling(uchar zhiling)
{
rs=0;
re=0;
delay(1);
P0=zhiling;
delay(2);
re=1;
delay(2);
re=0;
}
void wshuju(uchar shuju)
{ rs=1;
re=0;
delay(2);
P0=shuju;
delay(2);
re=1;
delay(2);
re=0;
}
void INIT()
{
wzhiling(0x38);
delay(1);
wzhiling(0x0c);
delay(1);
wzhiling(0x06);
delay(1);
wzhiling(0x01);
delay(1);
}
void main()
{
uchar num=0;
INIT();
while(1)
{ P3=0x00;
ale=1;
st=0; //此三條為啟動程序
st=1;
st=0;
while(!eoc); // 等待轉換完畢的信號,eoc=1是轉換完畢;
oe=1; //輸出三態門打開,將轉換的結果輸出到數據總線上
getdata=P1;
oe=0;
getdata=getdata*100/51;
tab[0]=0x30+getdata/100;
tab[2]=0x30+getdata%100/10;
tab[3]=0x30+getdata%10;
for(num=0;num<4;num++)
{
wzhiling(0x80+0x00+num);
wshuju(tab[num]);
}
}
}
復制代碼
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1