burn multiple 7segment at a time

Discussion in 'General Electronics Chat' started by neeer, Apr 12, 2012.

  1. neeer

    Thread Starter New Member

    Feb 15, 2012
    3
    0
    i want to run multiple 7 segment display at a time but i am getting problem in my code..please have a look on code and help me..

    i am using 8051MCU,74HC138,ULN 2803 as decoder n switch...
    this code is for common cathode displays..i am selecting 2 displays..

    #include<reg51.h>
    sbit c = P1^0;
    sbit b = P1^1;
    sbit a = P1^2;
    sfr seven_seg = 0xA0;
    sbit en = P3^3;

    unsigned char list[11] = {0x00,0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};

    unsigned int i,j;
    unsigned char *seg;

    void disp1();
    void disp2();
    void delay(unsigned int k)

    void main()
    {
    while(1){

    disp1();
    seven_seg = *seg;
    delay(20);
    seg++;

    disp2();
    seven_seg = *seg;
    delay(50);
    seg++;
    }//while
    }//main

    void disp1()
    {
    en = 0;
    c=0;
    b=0;
    a=0;
    }

    void disp2()
    {
    en = 0;
    c=0;
    b=0;
    a=1;
    }

    void delay(unsigned int k)
    {
    for( i = 0; i < k; i ++ )
    for(j= 0; j < k; j ++ ) ;
    }
    plz help me,correct me if m using pointer wrongly n about delay


    also my second qn is how we should calculate delay?( in ms,ns )
     
  2. panic mode

    Senior Member

    Oct 10, 2011
    1,318
    304
    use CODE tag (icon with "#") when posting code , it preserves formatting and makes it more readable:

    Code ( (Unknown Language)):
    1. #include<reg51.h>
    2. sbit c = P1^0;
    3. sbit b = P1^1;
    4. sbit a = P1^2;
    5. sfr seven_seg = 0xA0;
    6. sbit en = P3^3;
    7.  
    8. unsigned char list[11] = {0x00,0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
    9.  
    10. unsigned int i,j;
    11. unsigned char *seg;
    12.  
    13. void disp1();
    14. void disp2();
    15. void delay(unsigned int k)
    16.  
    17. void main()
    18. {
    19. while(1){
    20.  
    21.    disp1();
    22.       seven_seg = *seg;
    23.    delay(20);
    24.       seg++;
    25.    
    26.   disp2();
    27.     seven_seg = *seg;
    28.   delay(50);
    29.     seg++;
    30.  }//while
    31. }//main
    32.  
    33. void disp1()
    34. {
    35. en = 0;
    36. c=0;
    37. b=0;
    38. a=0;
    39. }
    40.  
    41. void disp2()
    42. {
    43. en = 0;
    44. c=0;
    45. b=0;
    46. a=1;
    47. }
    48.  
    49. void delay(unsigned int k)
    50. {
    51.  for( i = 0; i < k; i ++ )
    52.   for(j= 0; j < k; j ++ ) ;
    53. }
     
Loading...