Sign In

Trouble In 7 Segment Display Pic16f877a Program

jay patel jay3181996@gmail.com India

Hardware: Pic16f8771 Proties Actually Software: MikroC For Pic

actually all seven segment working together. like 1111,2222,3333

Images

Program


void tempdelayms(int d)
{int i,j;
 for(i=0;i<d;i++)
   {
    for(j=0;j<100;j++)
    {
    }
   }
}
void main()
{   //  char seg_code[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
     char seg_code1[]={0X3F,0X06,0X5d,0X4F,0X66,0X6b,0X7b,0X0e,0X7F,0X6f};
      char seg_code[]={0X3F,0X06,0X5b,0X4F,0X99,0X6d,0Xfd,0X7,0X7F,0X6f};
    int cnt, num, temp,temp1,temp2,temp3,i;


    TRISB = 0x00;
    portb=0x00;
    TRISC.RC0=0;
    TRISC.RC1=0;
    TRISC.RC2=0;
    TRISC.RC3=0;
            PORTC.RC0=0;
            PORTC.RC1=0;
            PORTC.RC2=0;
            PORTC.RC3=0;
    while (1)
    {
        for (cnt = 0; cnt <= 9999; cnt++)
        {
            for (i = 0; i < 100; i++)
            {
              switch(i)
              {
               case 0:
                num = cnt;
                temp = num / 1000;
                num = num % 1000;
                 PORTC.RC0=1;
                 PORTC.RC1=0;
                 PORTC.RC2=0;
                 PORTC.RC3=0;

                  //PORTC.RC4=1;
              //  PORTB = seg_code[temp];
              //  PORTB = seg_code[temp1];
              //  PORTB = seg_code1[temp2];
             //   PORTB = seg_code1[temp3];
                 tempdelayms(200);
              //  break;
                // tempdelayms(100);
     case 1:
                temp1 = num / 100;
                num = num % 100;
                PORTC.RC0=0;
                PORTC.RC1=1;
                PORTC.RC2=1;
                PORTC.RC3=1;
              //  PORTC.RC4=1;
           //   PORTB = seg_code[temp];
             //   PORTB = seg_code[temp1];
             //   PORTB = seg_code1[temp2];
             //   PORTB = seg_code1[temp3];
                   tempdelayms(200);
               // break;
               // tempdelayms(100);
        case 2:
                temp2 = num / 10;
                //temp = num % 100;
                PORTC.RC0=0;
                 PORTC.RC1=1;
                 PORTC.RC2=1;
                 PORTC.RC3=1;
               //  PORTC.RC4=1;
           //    PORTB = seg_code[temp];
           //    PORTB = seg_code[temp1];
              //  PORTB = seg_code1[temp2];
                   tempdelayms(200);
               // break;
                //tempdelayms(100);
             case 3:
                //temp = num / 100;
                temp3 = num % 10;
                PORTC.RC0=1;
                 PORTC.RC1=1;
                 PORTC.RC2=1;
                 PORTC.RC3=1;
                // PORTC.RC4=1;
               // PORTB = seg_code[temp];
               // PORTB = seg_code[temp1];
                //PORTB = seg_code1[temp2];
             //   PORTB = seg_code1[temp3];
                   tempdelayms(200);
               break;
               
                PORTB = seg_code[temp];
                 tempdelayms(200);
                PORTB = seg_code[temp1];
                 tempdelayms(200);
                PORTB = seg_code1[temp2];
                 tempdelayms(200);
                PORTB = seg_code1[temp3];
                            tempdelayms(200);
                }
            }
        }
    }
}

Post a reply to jay patel

Think you can help jay patel ? Then post your thoughts that might help jay patel. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.