Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Reply To: Need Help On Binary To Decimal 7 Seg. Display

Home Forums MikroC Pro for PIC Project Discussions Need Help On Binary To Decimal 7 Seg. Display Reply To: Need Help On Binary To Decimal 7 Seg. Display

#3846

Bitahwa Bindu
Keymaster

Hi. As we have explained in this tutorial: https://www.studentcompanion.co.za/multiplexing-of-7-segment-displays-with-pic-microcontroller-mikroc/

You can use the same multiplexing technique to display your counter. Then each time increment the value of counter by 1:

// assuming the enabling pins of the 2 seven segment displays are connected to RA0 and RA1.
#define Digit1 PORTA.RA0
#define Digit2 PORTA.RA1
 
unsigned char Display (unsigned char digit)
  {
    unsigned char pattern;
    unsigned char  SEGMENT_MAP[10] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
    pattern =  SEGMENT_MAP[digit] ;  //The pattern to return
    return (pattern);
  }
 
void main() {
  unsigned char MSD, LSD;
int count;
  ANSELA = 0;           // Configure PORTA as digital I/O
  ANSELB = 0;           // Configure PORTB as digital I/O
  TRISA = 0;            // Configure PORTA as outputs
  TRISB = 0;            // Configure PORTA as outputs
 
 Digit1 = 0;            //Disable digit 1
 Digit2 = 0;            //Disable digit 2
 
  while(1){
 
       MSD = count / 10;       //Extract MSD from count.
       LATB = Display(MSD);    //Display the MSD
       Digit2 = 1;             //Enable digit 2
       Delay_Ms(10);            //a short 10ms delay
       Digit2 = 0;             //Disable digit 2
 
       LSD = count % 10;        // LSD digit
       LATB = Display(LSD);    //Display the LSD
       Digit1 = 1;             //Enable digit 1
       Delay_Ms(10);            //a short 10ms delay
       Digit1 = 0;             //Disable digit 1
count++; //increment count by 1
    }
}