資源簡介
CT107D單片機綜合訓練平臺藍橋杯單片機開發程序,此代碼是本人參加藍橋杯比賽前訓練所寫!

代碼片段和文件信息
#include?“reg52.h“
#include?“intrins.h“
#include?“iic.h“
#include?“wave.h“
unsigned?int?FlagTime0=0;
unsigned?char?distanceLedFlagLedShan=0;
unsigned?char?i=0j=0y=0z=0v=0w=0;
void?Int0Init()
{
//設置INT0
IT0=1;//跳變沿出發方式(下降沿)
EX0=1;//打開INT0的中斷允許。
EA=1;//打開總中斷
}
void?timer0Init()
{
TMOD|=0X01;//選擇為定時器0模式,工作方式1,僅用TR0打開啟動。
TH0=0XFC; //給定時器賦初值,定時1ms
TL0=0X18;
ET0=1;//打開定時器0中斷允許
EA=1;//打開總中斷
TR0=0;//打開定時器
}
void?main()
{
iic_read(); //讀iic
Int0Init();
timer0Init();
AA1:?InitStop(); ??//關掉蜂鳴器和LED燈
Timer1Init();?//T1初始化
while(1)
{
distance?=?GetDistance();?//測出距離
if(s4==0)
{
delayms(100);
if(s4==0)
{
i++;
if(i>4)
i=0;
shu[0]=shu[1];
shu[1]=distance;
formalshu[i-1]=distance;
delayms(100);
TR0=1;
}
}
if(w>2)
{
w=0;
TR0=0;
}
iic_write(); //寫??iic
displayseg1(shu[0]shu[1]);????//數碼管顯示
if(shu[1] {
y=0;
dac_pcf8591(y);
}
else?
if(shu[1]>x)
{
y=(shu[1]-x)*0.02;
dac_pcf8591(y);
}
delayms(5);
if(s6==0)
{
delayms(100);
if(s6==0)
{
P2?=?0x80;
????????P0?=?0xbf;
while(1)
{
if(s7==0)
{
delayms(100);
if(s7==0)
{
x+=10;
}
if(x==40)
x=0;
}
displayseg3(x);
delayms(10);
if(s6==0)
{
delayms(100);
if(s6==0)
{
P2?=?0x80;
P0?=?0xff;
goto?AA1;
}
}
}
}
}
}
}
void?Int0()?interrupt?0
{
while(1)
{
P2?=?0x80;
????P0?=?0x7f;
if(s7==0)
{
delayms(100);
if(s7==0)
{
j++;
if(j>3)
j=0;
delayms(10);
}
}
displayseg2(formalshu[j]j+1);????//數碼管顯示
if(s6==0|s4==0)
{
P2?=?0x80;
P0?=?0xff;
break;
}
???}
}
void?timer0()?interrupt?1
{
TH0=0XFC; //給定時器賦初值,定時1ms
TL0=0X18;
v++;
if(v%1000==0)
{
P2?=?0x80;
P0?=?0xfe;
delayms(5);
w++;
}
else
{
P2?=?0x80;
P0?=?0xff;
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2813??2018-12-01?20:35??藍橋杯第十四個程序超聲波測距\iic.h
?????文件??????14150??2019-03-20?20:54??藍橋杯第十四個程序超聲波測距\Listings\STARTUP.lst
?????文件???????6091??2019-03-20?20:54??藍橋杯第十四個程序超聲波測距\Listings\wave.lst
?????文件??????32670??2019-03-20?20:54??藍橋杯第十四個程序超聲波測距\Listings\wave.m51
?????文件????????819??2019-03-20?20:54??藍橋杯第十四個程序超聲波測距\ob
?????文件??????23291??2019-03-20?20:54??藍橋杯第十四個程序超聲波測距\ob
?????文件???????1032??2019-03-20?20:54??藍橋杯第十四個程序超聲波測距\ob
?????文件???????6604??2019-03-20?20:54??藍橋杯第十四個程序超聲波測距\ob
?????文件?????????99??2019-03-20?20:54??藍橋杯第十四個程序超聲波測距\ob
?????文件??????25202??2019-03-20?20:54??藍橋杯第十四個程序超聲波測距\ob
?????文件???????6376??2015-05-29?12:09??藍橋杯第十四個程序超聲波測距\STARTUP.A51
?????文件???????2295??2018-12-02?10:36??藍橋杯第十四個程序超聲波測距\wave.c
?????文件???????6660??2018-12-01?19:49??藍橋杯第十四個程序超聲波測距\wave.h
?????文件??????71629??2019-03-21?11:27??藍橋杯第十四個程序超聲波測距\wave.uvgui.chenbing
?????文件???????5358??2019-03-21?11:21??藍橋杯第十四個程序超聲波測距\wave.uvopt
?????文件??????13958??2019-03-20?12:50??藍橋杯第十四個程序超聲波測距\wave.uvproj
?????文件?????340582??2018-11-27?21:44??藍橋杯第十四個程序超聲波測距\試題\藍橋杯第二次訓練題目(15)?(1).pdf
?????目錄??????????0??2019-05-21?12:51??藍橋杯第十四個程序超聲波測距\Listings
?????目錄??????????0??2019-05-21?12:51??藍橋杯第十四個程序超聲波測距\ob
?????目錄??????????0??2019-05-21?12:51??藍橋杯第十四個程序超聲波測距\試題
?????目錄??????????0??2019-05-21?12:51??藍橋杯第十四個程序超聲波測距
-----------?---------??----------?-----??----
???????????????559629????????????????????21
- 上一篇:R語言SVR代碼
- 下一篇:2019年電賽H題_模擬電磁曲射炮.rar
評論
共有 條評論