sayf alawneh
Junior Member level 3
- Joined
- Aug 15, 2014
- Messages
- 27
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 256
2 common cathode 7 segments and pic 16f877a and mikroc pro for pic
2 transistors connected with RD0 and RD1 , the RD0 transistor is responsible about the tens digit and the RD1 transistor is responsible about the ones digit the 2 common cathode 7 segments are connected to portb
code :
2 transistors connected with RD0 and RD1 , the RD0 transistor is responsible about the tens digit and the RD1 transistor is responsible about the ones digit the 2 common cathode 7 segments are connected to portb
code :
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 char x,y=0; // x for ones and y for 10s char I; unsigned short mask(unsigned short num){ switch(num){ case 0:return 0x3f; case 1:return 0x06; case 2:return 0x5B; case 3:return 0x4F; case 4:return 0x66; case 5:return 0x6D; case 6:return 0x7D; case 7:return 0x07; case 8:return 0x7F; case 9:return 0x6F; } } void main() { TRISB=0;// PORTB is output TRISD=0;// PORTD is output PORTB=0;// initialize PORTB PORTD=0;// initialize PORTD for(;;){ // ifinite loop for (I=0;I<200;I++){ // delay_1second for the counter since every digit takes 5 ms PORTD=1; // PORTD=0B00000001; transistor on RD0 is enabled and transistor on RD1 is disabled PORTB=mask(y); //tens digit delay_ms(5);// eye delay PORTD=2; // PORTD=0B00000010; transistor on RD1 is enabled and transistor on RD0 is disabled PORTB=mask(x); //ones digit delay_ms(5); // eye dealy } x++; if(x==10){x=0;y++;if(y==10)y=0;} } }
Last edited: