流水灯+蜂鸣器

//蜂鸣器
#include<reg51.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp;
sbit beep=P2^3;
sbit D1=P1^0;
void deplay();
/*void main()
{
 while(1)
 {
  D1=0;
  deplay();
  D1=1;
  deplay();
 }
}*/

void main()
{
 temp=0xfe;
 P1=temp;
 beep=0;
 while(1)
 {
  temp=_crol_(temp,1);
  deplay();
  P1=temp;
  deplay();
 }
}
void deplay()
{
      uint x,y;
  for(x=1000;x>0;x--)
     for(y=20;y>0;y--) ;
}
//流水灯+蜂鸣器

今天做好了第一个程序,呵呵,实现了自己想做的东西,还是很开心的

原文地址:https://www.cnblogs.com/yuelingzhi/p/2209457.html