2、8个二极管来回亮,每次亮蜂鸣器滴滴两声;
#include<reg52.h>
#include<intrins.h>#define uint unsigned int#define uchar unsigned charuint x,y,z;uchar temp;sbit b=P2^3;void delay(uint);void main(){ temp=0xfe; P1=temp; while(1) { b=0; delay(100); b=1; delay(100); b=0; delay(100); b=1; delay(620); temp=_crol_(temp,1); P1=temp; }}void delay(uint z){ for(x=z;x>0;x--) for(y=100;y>0;y--);}