Friday, June 7, 2013

Microrocontroller & Seven Segments- Counter 00 to 99 - Method3

In this tutorial, we will make a counter from 00 to 99 using two seven segment decoder and two latch registers
Code:
void main() {
         unsigned char tensCounter , onesCounter ;
         TRISB = 0 ; PORTB = 0 ;
         TRISC = 0 ; PORTC = 0 ;
        
         while(1)
         {
                
                  for(tensCounter = 0 ; tensCounter <= 9 ; tensCounter++)
                 {

                       PORTB = tensCounter ;

                       PORTC.F1 = 1 ;
                       Delay_ms(10) ;
                       PORTC.F1 = 0 ;

                       for(onesCounter = 0 ; onesCounter <= 9 ; onesCounter++)
                       {
                              PORTB = onesCounter ;

                              PORTC.F0 = 1 ;
                              Delay_ms(10) ;
                              PORTC.F0 = 0 ;

                              Delay_ms(500) ;
                       }
                }
         }
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...