爆炸(倒计时十秒)

来源:互联网 发布:淘宝客开通流程 编辑:程序博客网 时间:2024/05/17 23:46
#include <reg51.h>sbit SPK=P1^2;    //定义喇叭端口void delay_1s();void delay(unsigned char i);unsigned char led[10] ={0x6f,0x7f,0x07,0x7d,0x6d,0x66,0x4f,0x5b,0x06,0x3f};unsigned char i,j;void main(void){TMOD = 0X01;TH0 = 0X3C;TL0 = 0Xb0;TR0 = 1;j = 0;while(1){//for(j = 0;j < 8;j++)//{SPK=!SPK;P0 = ~led[j];delay_1s();    SPK=!SPK;P0 = 0xff;delay_1s();j++;if(j == 9){while(1){P0 = ~0x3f;SPK=!SPK;}}//}}}void delay_1s(){unsigned char i;for(i = 0;i < 20;i++){while(!TF0)  ;TF0 = 0;TH0 = 0X3C;TL0 = 0XB0;}}

0 0
原创粉丝点击