Cyrus the Great
Member level 4
hi.i want program my micro for counting by pushing button.i write half of my programming which can count and show the number on 7-segment.i want make it down counter by another button. please help me.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 #include <mega16.h> char digits[16]={0x3F,0x06,0x5B,0x4F,0x66,0x6D, 0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71}; unsigned char; unsigned char p_state; unsigned char key; unsigned char i; void main(void) { DDRD = 0xFF; PORTD = digits[0]; DDRC = 0x00; PORTC = 0xFF; while(1) { if(!PINC.0) { if(key!=p_state) { if(i==15) { i=0; PORTC=digits[0]; } else i++; PORTD = digits[i]; p_state=key; }; } else p_state=0xFF; }
Last edited by a moderator: