蓝球24秒计时器 源程序和电路图初学51用延时做的24秒计时器
#include unsigned char code time[]={0x59,0x58,0x57,0x56,0x55,0x54,0x53,0x52,0x51,0x50,0x49,0x48,0x47, 0x46,0x45,0x44,0x43,0x42,0x41,0x39,0x38,0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x30,0x29,0x28,0x27,0x26,0x25,0x24,0x23,0x22,0x21,0x20,0x19,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x09,0x08,0x07,0x06,0x05,0x04,0x03, 0x02,0x01,0x00}; unsigned char Second; unsigned char timer; unsigned char fen; void delays() { unsigned char i,j,k; for(k=100;k>0;k--) for(i=20;i>0;i--) for(j=248;j>0;j--); } void main() { TMOD=0X02; EX0=1; EA=1; fen=47; timer=0; Second=34; P2=time[Second]; P1=time[timer]; P0=time[fen]; while(1) { delays(); Second++; timer++; if(Second==59) { Second=34; } P2=time[Second]; if(timer==59) { ++fen; timer=0; } if(fen==59) fen=47; P1=time[timer]; P0=time[fen]; } } void int0() interrupt 0 using 0 { Second=34; P2=time[Second]; } 0x02,0x01,0x00}; unsigned char Second; unsigned char timer; unsigned char fen; void delays() { unsigned char i,j,k; for(k=100;k>0;k--) for(i=20;i>0;i--) for(j=248;j>0;j--); } void main() { TMOD=0X02; EX0=1; EA=1; fen=47; timer=0; Second=34; P2=time[Second]; P1=time[timer]; P0=time[fen]; while(1) { delays(); Second++; timer++; if(Second==59) { Second=34; } P2=time[Second]; if(timer==59) { ++fen; timer=0; } if(fen==59) fen=47; P1=time[timer]; P0=time[fen]; } } void int0() interrupt 0 using 0 { Second=34; P2=time[Second]; }
用户评论