單片機(jī)控制的報(bào)警器系統(tǒng)
圖一
圖二
#include"reg51.h"#include"intrins.h"#define uchar unsigned charuchar count;bit flag;sbit BEEP=P3^7;void delay500(){uchar i;for(i=250;i>0;i--){_nop_();}}void main(){EA=1;EX0=1;while(1);{}}void timer() interrupt 0{for(count=150;count>0;count--){BEEP=~BEEP;delay500();}for(count=250;count>0;count--){BEEP=~BEEP;delay500();delay500();}}
評(píng)論