Professional Documents
Culture Documents
Electronic Dice
Electronic Dice
2 #define D4 PORTC.3 #define D5 PORTC.4 #define D6 PORTC.5 #define D7 PORTC.6 void main(void) { int DICE=0; DDRB=0x00; DDRC=0Xff; PORTC=0x00; DDRD=0xff; PORTD=0x00; while(1) { if(sw==1) { switch(DICE) { case 1:D4=on; break; case 2:D3=on; D5=on;
break; case 3:D3=on; D4=on; D5=on; break; case 4:D1=on; D2=on; D6=on; D7=on; break; case 5:D4=on; D1=on; D6=on; D2=on; D7=on; break; case 6:D3=on; D1=on; D2=on; D6=on; D7=on; D5=on; break; } delay_ms(100); PORTC=0x00; } else { DICE++; PORTD=DICE; PORTC=0x00; if(DICE==7) DICE=1; }}}