#include <reg51.h>
sbit k=P1^7;
sbit beep=P1^0;
#define uint unsigned int
#define uchar unsigned char
void delayms(xms)
{
uint m,n;
for(m=xms;m>0;m--)
for(n=110;n>0;n--);
}
void T0_int() interrupt 1
{
uint i;
TH0=(65536-500)/256;
TL0=(65536-500)%256;
i++;
beep=~beep;
if(i==200)
i=0;
TR0=~TR0;
}
void T1_int() interrupt 3
{
uint a;
TH1=(65536-1000)/256;
TL1=(65536-1000)%256;
a++;
beep=~beep;
if(a==200)
a=0;
TR1=~TR1;
}
void main()
{
TH0=(65536-500)/256;
TL0=(65536-500)%256;
TH1=(65536-1000)/256;
TL1=(65536-1000)%256;
EA=1;
ET1=1;
ET0=1;
while(1);
}
开关怎么加,新人求大神!!
|