【电子设计】基于8051和PROTEUS仿真案列:按键发音.pdfVIP

  • 2
  • 0
  • 约小于1千字
  • 约 1页
  • 2022-05-23 发布于湖南
  • 举报

【电子设计】基于8051和PROTEUS仿真案列:按键发音.pdf

基于8051 和PROTEUS 仿真案列 按键发音 /* 名称:按键发音 说明:按下不同的按键会是SOUNDER 发出不同频率的声音。本例使用延时函数实现不同频率的声音 输出,以后也可使用定时器 */ #includereg51.h #define uchar unsigned char #define uint unsigned int sbit BEEP=P3^7; sbit K1=P1^4; sbit K2=P1^5; sbit K3=P1^6; sbit K4=P1^7; //延时 void DelayMS(uint x) { uchar t; while(x--) for(t=0;t120;t++); } //按周期t 发音 void Play(uchar t) { uchar i; for(i=0;i100;i++) { BEEP=~BEEP; DelayMS(t); } BEEP=0; } void main() { P1=0xff; BEEP=0; while(1) { if(K1==0) Play(

文档评论(0)

1亿VIP精品文档

相关文档