0

I doing a small project with 6 display 7 segment (I will call A1, A2, A3, A4, A5, A6) and 3 cd4543B (I will call Da, Db, Dc) with an arduino mega 2560. I also use 6 transistor to control power supply of display.

Da is use for A1, A2

Db is use for A3, A4

Dc is use for A5, A6

The circuit is done, and work if I use only 4 display I have tried different combination (A1, A2, A3, A4, or A1, A2, A5, A6 or A2, A3, A4, A5, or A3, A4, A5, A6) and all work well.

but If I want to use five or six display, nothing work....

here a diagram of my circuit

there is resistance for each segment of each display which not appear on the diagram.

my code for 5 display :

//Da
const int bit_A=8;
const int bit_B=9;
const int bit_C=10;
const int bit_D=11;
//Db
const int bit_E=22;
const int bit_F=24;
const int bit_G=26;
const int bit_H=28;
//Dc
const int bit_I=40;
const int bit_J=42;
const int bit_K=44;
const int bit_L=46;

// transistors
const int alim_dizainemillier= 3;
const int alim_millier=4;
const int alim_centaine=5;
const int alim_dizaine=6;
const int alim_unite=7;

void setup()
{

pinMode(bit_A,OUTPUT);
pinMode(bit_B,OUTPUT);
pinMode(bit_C,OUTPUT);
pinMode(bit_D,OUTPUT);
pinMode(bit_E,OUTPUT);
pinMode(bit_F,OUTPUT);
pinMode(bit_G,OUTPUT);
pinMode(bit_H,OUTPUT);
pinMode(bit_I,OUTPUT);
pinMode(bit_J,OUTPUT);
pinMode(bit_K,OUTPUT);
pinMode(bit_L,OUTPUT);
pinMode(alim_dizainemillier,OUTPUT);
pinMode(alim_millier,OUTPUT);
pinMode(alim_centaine,OUTPUT);
pinMode(alim_dizaine,OUTPUT);
pinMode(alim_unite,OUTPUT);

digitalWrite(bit_A,LOW);
digitalWrite(bit_B,LOW);
digitalWrite(bit_C,LOW);
digitalWrite(bit_D,LOW);
digitalWrite(bit_E,LOW);
digitalWrite(bit_F,LOW);
digitalWrite(bit_G,LOW);
digitalWrite(bit_H,LOW);
digitalWrite(bit_I,LOW);
digitalWrite(bit_J,LOW);
digitalWrite(bit_K,LOW);
digitalWrite(bit_L,LOW);
digitalWrite(alim_dizainemillier,LOW);
digitalWrite(alim_millier,LOW);
digitalWrite(alim_centaine,LOW);
digitalWrite(alim_dizaine,LOW);
digitalWrite(alim_unite,LOW);  
}

void loop() 
{
 for(int i=0;i<100000;i++)
 {
   afficher_nombre(i);

 }
}




void afficher_nombre(int nombre)

{
 long temps;
 int unite=0,dizaine=0,centaine=0, millier=0, dizainemillier=0;
 dizainemillier=nombre/10000;
 millier=(nombre-(10000*dizainemillier))/1000;
 centaine=(nombre-1000*millier)-(10000+dizainemillier)/100;
 dizaine=(nombre-(centaine*100)-(millier*1000)-(dizainemillier*10000))/10;
 unite=nombre-(dizainemillier*10000)-(millier*1000)-(centaine*100)-(dizaine*10);

 temps=millis();
 while((millis()-temps)<500){   



    digitalWrite(alim_dizainemillier,HIGH);
    afficher_CD(dizainemillier);
    digitalWrite(alim_millier,LOW);
    digitalWrite(alim_centaine,LOW);
    digitalWrite(alim_dizaine,LOW);
    digitalWrite(alim_unite,LOW);
    delay(5);


    digitalWrite(alim_dizainemillier,LOW);
    digitalWrite(alim_millier,HIGH);
    afficher_CM(millier);
    digitalWrite(alim_centaine,LOW);
    digitalWrite(alim_dizaine,LOW);
    digitalWrite(alim_unite,LOW);
    delay(5);


   digitalWrite(alim_dizainemillier,LOW);
   digitalWrite(alim_millier,LOW);
   digitalWrite(alim_centaine,HIGH);
   afficher_CM(centaine);
   digitalWrite(alim_dizaine,LOW);
   digitalWrite(alim_unite,LOW);
   delay(5);


   digitalWrite(alim_dizainemillier,LOW);
   digitalWrite(alim_millier,LOW);
   digitalWrite(alim_centaine,LOW);
   digitalWrite(alim_dizaine,HIGH);
   afficher_UD(dizaine);
   digitalWrite(alim_unite,LOW);
   delay(5);

   digitalWrite(alim_dizainemillier,LOW);
   digitalWrite(alim_millier,LOW);
   digitalWrite(alim_centaine,LOW);
   digitalWrite(alim_dizaine,LOW);
   digitalWrite(alim_unite,HIGH);
   afficher_UD(unite);
   delay(5);
 }
}


void afficher_UD(int chiffre)
{
  digitalWrite(bit_A,LOW);
  digitalWrite(bit_B,LOW);
  digitalWrite(bit_C,LOW);
  digitalWrite(bit_D,LOW);

      if(chiffre>=8)
         {
           digitalWrite(bit_D,HIGH);
           chiffre=chiffre-8;
         }
     if(chiffre>=4)
         {
           digitalWrite(bit_C,HIGH);
           chiffre=chiffre-4;
         }
    if(chiffre>=2)
         {
           digitalWrite(bit_B,HIGH);
           chiffre=chiffre-2;
         }
    if(chiffre>=1)
         {
           digitalWrite(bit_A,HIGH);
           chiffre=chiffre-1;
         }
}


void afficher_CM(int chiffre)
{
  digitalWrite(bit_E,LOW);
  digitalWrite(bit_F,LOW);
  digitalWrite(bit_G,LOW);
  digitalWrite(bit_H,LOW);

      if(chiffre>=8)
         {
           digitalWrite(bit_H,HIGH);
           chiffre=chiffre-8;
         }
     if(chiffre>=4)
         {
           digitalWrite(bit_G,HIGH);
           chiffre=chiffre-4;
         }
    if(chiffre>=2)
         {
           digitalWrite(bit_F,HIGH);
           chiffre=chiffre-2;
         }
    if(chiffre>=1)
         {
           digitalWrite(bit_E,HIGH);
           chiffre=chiffre-1;
         }
}

void afficher_CD(int chiffre)
{
  digitalWrite(bit_I,LOW);
  digitalWrite(bit_J,LOW);
  digitalWrite(bit_K,LOW);
  digitalWrite(bit_L,LOW);

      if(chiffre>=8)
         {
           digitalWrite(bit_L,HIGH);
           chiffre=chiffre-8;
         }
     if(chiffre>=4)
         {
           digitalWrite(bit_K,HIGH);
           chiffre=chiffre-4;
         }
    if(chiffre>=2)
         {
           digitalWrite(bit_J,HIGH);
           chiffre=chiffre-2;
         }
    if(chiffre>=1)
         {
           digitalWrite(bit_I,HIGH);
           chiffre=chiffre-1;
         }
}

I don't understand why it's not working. Could it be a power supply problem ? even if there is never two display used at the same time (delay between them, see code)

Thanks a lot for any help.

1

Try this link Arduino and CD4543

To control a common cathode seven segment display using CD4543

PH ( Pin 6 ) should be set LOW.
LD ( Pin 1 ) should be set HIGH.
BL ( Pin 7 ) should be set LOW.

enter image description here

Try this code for each segment, could be faulty segment too :)

int Ph  = 6;      //arduino pin connected to the Ph pin of 4543
int BL  = 5;     //arduino pin connected to the BL pin of 4543
int LD  = 11;   //arduino pin connected to the LD pin of 4543


int A   = 7;
int B   = 9;
int C   = 10;
int D   = 8;

void setup()
{     
    // Declare all the pins as OUTPUT pins

  pinMode(Ph,  OUTPUT);
  pinMode(BL,  OUTPUT);
  pinMode(LD, OUTPUT);

  pinMode(A , OUTPUT);
  pinMode(B  , OUTPUT);
  pinMode(C  , OUTPUT); 
  pinMode(D, OUTPUT);

}

void loop()
{

    // Display 0

  digitalWrite(Ph,  LOW); 
  digitalWrite(BL,  LOW);   
  digitalWrite(LD,  HIGH); 

  digitalWrite(A , LOW); 
  digitalWrite(B , LOW);   
  digitalWrite(C , LOW);
  digitalWrite(D , LOW);

  delay(1000);

    // Display 1

  digitalWrite(A , HIGH); 
  digitalWrite(B , LOW);   
  digitalWrite(C , LOW);
  digitalWrite(D , LOW);

  delay(1000);

    // Display 2

  digitalWrite(A , LOW); 
  digitalWrite(B , HIGH);   
  digitalWrite(C , LOW);
  digitalWrite(D , LOW);

  delay(1000);

    // Display 3

  digitalWrite(A , HIGH); 
  digitalWrite(B , HIGH);   
  digitalWrite(C , LOW);
  digitalWrite(D , LOW);

  delay(1000);

    // Display 4

  digitalWrite(A , LOW); 
  digitalWrite(B , LOW);   
  digitalWrite(C , HIGH);
  digitalWrite(D , LOW);

  delay(1000); 
}
-1

The circuit is done,

unnecessarily complex: you can share the data lines among the drivers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.