|
借你寶地求助大神 同時(shí)也滿足你的要求
問(wèn)題是把數(shù)組改成Int型程序就出錯(cuò) 只能發(fā)出25個(gè)數(shù)組
#include<reg52.h>
sbit button=P2^0;
sbit ir=P1^0;
unsigned int irtime;
char b,y;
char timedata[32]={80,35,35,35,35,35,35,35,35,80,80,80,80,80,80,80,35,35,80,80,35,35,35,35,80,80,35,35,80,80,80,80, };
void timer0()interrupt 1 //定時(shí)器中斷
{
irtime++;
if(b==1)
{
ir=~ir; //取反 如果是1就變成0
}
}
void main()
{
int x;
ET0=1; //允許定時(shí)器0的中斷
EA=1; //打開(kāi)總中斷
TMOD=0X02;//定時(shí)器0工作方式2 自動(dòng)重裝定時(shí)器
TH0=0Xe6; //裝初值25.8us
TL0=0Xe6; //裝初值25.8us
TR0=0; //開(kāi)啟定時(shí)器T0
ir=0;
x=0;
if(y==0)
{
TR0=1;
b=1;
irtime=0;
while(irtime<320);//320
b=0;
ir=0;
while(irtime<500);// 484
for(x=0;x<33;x++)
{
irtime=0;
b=1;
while(irtime<21);//18
b=0;
ir=0;
while(irtime<timedata[x]);
if(x>33)
break; //跳出循環(huán)
}
TR0=0;
y=1;
}
}
|
|