#include<reg52.h>
#include<stdlib.h>
#define uchar unsigned char
#define uint unsigned int
uchar num;
sbit p17=P1^7;
sbit p16=P1^6;
sbit p15=P1^5;
void t0isr() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
num++;
}
void main()
{
uchar temp1,temp2;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
ET0=1;
EA=1;
srand(9); //åå
¥éæå¼åå§åéæºå½æ°
temp1=rand();
temp2=rand();
if(temp1>7)
{
p17=0;p15=1;p16=1;
TR0=1;
num=0;
while(num<30);
TR0=0;
}
if((temp1<7)&&(temp2>7)
{
p16=0;p15=1;p17=1;
TR0=1;
num=0;
while(num<30);
TR0=0;
}
if((temp1<7)&&(temp2<7)
{
p15=0;p16=1;p17=1;
TR0=1;
num=0;
while(num<30);
TR0=0;
}
}
温馨提示:答案为网友推荐,仅供参考