|
用51单片机利用定时器设计的警报控制器+旋转灯(仿真图+c语言程序)
51单片机源码预览:
- #include<reg51.h>
- #include<intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- sbit SPK=P3^7;
- uchar frq=0x00;
- void delay(uint ms)
- {uchar i;
- while(ms--)
- for(i=0;i<200;i++);
- }
- void main()
- {
- P2=0X00;
- TMOD=0X11;
- TH0=0XFE;
- TL0=0X00;
- IT0=1;
- IE=0X8B;
- IP=0X01;
- TR0=0;
- TR1=0;
- while(1)
- {frq++;
- delay(1);}
- }
- void int0() interrupt 0
- {TR0=!TR0;
- TR1=!TR1;
- if(P2==0X00)
- P2=0XE0;
- else
- P2=0x00;
- }
- void int1() interrupt 1
- {TH0=0XFE;
- TL0=frq;
- SPK=~SPK;
- }
- void int2() interrupt 3
- {TH1=-4500>>8;
- TL1=-4500&0X1F;
- P2=_crol_(P2,1);
- }
复制代码
|
评分
-
查看全部评分
|