|
#include<reg51.h>
void time0_init();
void AD_0809();
sbit ST=P2^6;
sbit OE=P2^5;
sbit EOC=P2^4;
sbit CLK=P2^3;
sbit ALE=P2^6;
uchar v;
uint gatedate;
void main()
{
time0_init();
while(1)
{AD_0809();if(v>1&&v<4)
{
display();
t=14060/(v*v);
display();//數(shù)碼管顯示程序
while(a>=t)
{
OUT=1;
flag=1;
display();
}
}
void AD_0809()
{
ST=0;
_nop_();
OE=0;
_nop_();
ST=1;
_nop_();
ST=0;
while(EOC==0);
OE=1;
gatedate=P1;
_nop_();
OE=0;
v=gatedate*5/255;
}
void time0_init()
{
TMOD=0x12;
TH0=(65536-2)/256;
TL0=(65536-2)%256;
EA=1;
ET0=1;
TR0=1;
}
void timer0()interrupt 2
{
CLK=~CLK;
}
輸入電壓2V時(shí)數(shù)碼管顯示不了(應(yīng)該是進(jìn)入不了if判斷語(yǔ)句)并且無(wú)論輸入2.5V還是3V延時(shí)時(shí)間都一樣
|
|