|
  
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uint i,count;
sbit s1=P1^0;
void main()
{
TMOD=0x01;
TH1=(65536-60000)/256; //高8位
TL1=(65536-60000)%256; //低8位
P1=0x00;
EA=1; //打開(kāi)中斷總開(kāi)關(guān),1表示打開(kāi),0表示關(guān)閉
ET0=1; //打開(kāi)定時(shí)/計(jì)數(shù)器中斷0
TR0=1; //啟動(dòng)定時(shí)器
while(1);
{
if(s1==0)
count++;
if(count==20)
P1=0x00;
}
}
void interrupt_0()interrupt 1
{
TH1=(65536-60000)/256; //高8位
TL1=(65536-60000)%256; //低8位
count--;
if(i<=0)
{
i=20;
P1=~P1;
}
}
請(qǐng)問(wèn).png (58.98 KB, 下載次數(shù): 47)
下載附件
2019-12-23 15:24 上傳
|
|