蜂鸣器输出\模拟枪声\C51_果冻006的空间_百度空间

#include <reg51.h>
#include <intrins.h>

#define uchar unsigned char
#define uint unsigned int

sbit BEEP= P3^7;
sbit K1 = P1^4;

uchar H_count,L_count;

/*********************************************************/
void main()
{
BEEP=1;
    TMOD=0x01;
    TH0=0xff;
    TL0=0xa0;
    H_count=0xff;
    L_count=0xa0;     
    EA=1;
    ET0=1;
   
    while(1)
    {
       while(K1);
       TR0=1;
    }
}

/*********************************************************
Time0中断函数
**********************************************************/
void Time0(void) interrupt 1 using 0
{
BEEP=~BEEP;
if( L_count!=0x00 )
{
    L_count--;
    TH0=H_count;
       TL0=L_count;
       return;
     }else H_count--;
  
if( H_count!=0xfc )
{
    L_count--;
    TH0=H_count;
       TL0=L_count;
       return;
}
else
     {
        H_count=0xff;
        L_count=0xa0;
        TH0=H_count;
        TL0=L_count;
        BEEP=1;
        TR0=0;
     }  
}
  
/*********************************************************/



郑重声明:资讯 【蜂鸣器输出\模拟枪声\C51_果冻006的空间_百度空间】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——