//シンプルな時計 2003.9.18 小山智史(弘前大学) #include #include #include #include uint8_t d,i,j,k,c100ms,hh,mm,ss,DIGIT[4]; uint16_t cntr; prog_char LED[]={0x40, 0x79, 0x24, 0x30, 0x99, 0x92, 0x02, 0x58, 0x00, 0x18}; prog_char SEL[]={0x11, 0x12, 0x14, 0x18}; void countup(){ cntr=0; ss=0; if(++mm>=60){ mm=0; if(++hh>=12) hh=0; } } void wait(uint8_t n){ for(i=0;i=1000){ cntr=0; if(++ss>=60) countup(); } DIGIT[0]=mm%10; DIGIT[1]=mm/10; DIGIT[2]=hh%10; DIGIT[3]=hh/10; d=((DIGIT[3]==0)?3:4); outp(PRG_RDB(&LED[DIGIT[cntr%d]]),PORTD); outp(PRG_RDB(&SEL[cntr%d]),PORTB); } int main(void){ cntr=hh=mm=ss=0; outp(0x10,PORTB); outp(0x0f,DDRB); // xxxroooo outp(0x00,PORTD); outp(0x7f,DDRD); // xooooooo outp((1<=60){ for(k=0;k<10;k++) countup(); j--; }else if(j>10) countup(); } } }