need MULTIPLEXING 7 segment help

Hi guys, i'm currently doing a 6 digit 7 segment common cathode. Somehow i'm able to display the characters that i want. However, i dont know how to change the characters while display another cause it's in the loop . It will keep repeating. thus not showing the results i wanted.

Here the code, please tell me if i had any errors in there. And how to change the characters

below

#include <MsTimer2.h>
int A = 3;
int B = 4;
int C = 5;
int D = 6;
int E = 7;
int F = 8;
int G = 9;

int t6 = A1;
int t7 = A2;
int t5 = A0;
int t4= 10;
int t3 = 11;
int t2 = 12;
int t1 = 13;

int t8 = A3;

void setup()
{
  pinMode(A, OUTPUT);    // sets the digital pin as output
  pinMode(B, OUTPUT);
  pinMode(C, OUTPUT);
  pinMode(D, OUTPUT);
  pinMode(E, OUTPUT);
  pinMode(F, OUTPUT);
  pinMode(G, OUTPUT);
  pinMode(t1, OUTPUT);
  pinMode(t3, OUTPUT);
  pinMode(t2, OUTPUT);
  pinMode(t4, OUTPUT);
  pinMode(t5, OUTPUT); 
  pinMode(t7, OUTPUT);
  pinMode(t6, OUTPUT);
  pinMode(t8, OUTPUT);


box();

 

}


void AA (){
    digitalWrite(A,  HIGH);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,LOW);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
}
void BB(){
      digitalWrite(A,  LOW);
  digitalWrite(B,LOW);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
}
 void CC(){
  digitalWrite(A,  HIGH);
  digitalWrite(B,LOW);
  digitalWrite(C,LOW);
  digitalWrite(D,HIGH);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,LOW);
 }
 void DD(){
     digitalWrite(A,  LOW);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,HIGH);
  digitalWrite(F,LOW);
  digitalWrite(G,HIGH);
 }
 void EE()
{
    
  digitalWrite(A,  HIGH);
  digitalWrite(B,LOW);
  digitalWrite(C,LOW);
  digitalWrite(D,HIGH);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
}
void FF() {
     digitalWrite(A,  HIGH);
  digitalWrite(B,LOW);
  digitalWrite(C,LOW);
  digitalWrite(D,LOW);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
 }
 void GG(){
     digitalWrite(A,  HIGH);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,LOW);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
 }
void HH ()
{

  digitalWrite(A,  LOW);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,LOW);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
}

void LL()
 {
     
  digitalWrite(A,  LOW);
  digitalWrite(B,LOW);
  digitalWrite(C,LOW);
  digitalWrite(D,HIGH);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,LOW);
 }
 
 void oo(){
    
  digitalWrite(A,  LOW);
  digitalWrite(B,LOW);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,HIGH);
  digitalWrite(F,LOW);
  digitalWrite(G,HIGH);
 }
 void PP(){
     digitalWrite(A, HIGH);
  digitalWrite(B,HIGH);
  digitalWrite(C,LOW);
  digitalWrite(D,LOW);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
 }
 void ss(){
   digitalWrite(A,  HIGH);
  digitalWrite(B,LOW);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,LOW);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
 }
 void UU(){
     digitalWrite(A,  LOW);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,LOW);
 }

 
 
 void one(){
     digitalWrite(A,  LOW);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,LOW);
  digitalWrite(E,LOW);
  digitalWrite(F,LOW);
  digitalWrite(G,LOW);
 }
 void two(){
     digitalWrite(A,  HIGH);
  digitalWrite(B,HIGH);
  digitalWrite(C,LOW);
  digitalWrite(D,HIGH);
  digitalWrite(E,HIGH);
  digitalWrite(F,LOW);
  digitalWrite(G,HIGH);
 }
 void three(){
 
   digitalWrite(A,  HIGH);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,LOW);
  digitalWrite(F,LOW);
  digitalWrite(G,HIGH);
 }
 void four(){
     digitalWrite(A,  LOW);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,LOW);
  digitalWrite(E,LOW);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
 }
 void five(){
     digitalWrite(A,  HIGH);
  digitalWrite(B,LOW);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,LOW);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
 }

void six() {
   digitalWrite(A,  HIGH);
  digitalWrite(B,LOW);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH); 
}
void seven() {
    digitalWrite(A,  HIGH);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,LOW);
  digitalWrite(E,LOW);
  digitalWrite(F,LOW);
  digitalWrite(G,LOW);
}
void eight(){
    digitalWrite(A,  HIGH);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,HIGH);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
}
void nine(){
  digitalWrite(A,  HIGH);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  digitalWrite(D,HIGH);
  digitalWrite(E,LOW);
  digitalWrite(F,HIGH);
  digitalWrite(G,HIGH);
}
void first(){
  digitalWrite(t1,LOW);
  digitalWrite(t2,HIGH);
  digitalWrite(t3,HIGH);
  digitalWrite(t4,HIGH);
  digitalWrite(t5,HIGH);
  digitalWrite(t6,HIGH);
  digitalWrite(t7,HIGH);
  digitalWrite(t8,HIGH);
}
void second(){
    digitalWrite(t1,HIGH);
  digitalWrite(t2,LOW);
  digitalWrite(t3,HIGH);
  digitalWrite(t4,HIGH);
  digitalWrite(t5,HIGH);
  digitalWrite(t6,HIGH);
  digitalWrite(t7,HIGH);
  digitalWrite(t8,HIGH);
}
void third(){
    digitalWrite(t1,HIGH);
  digitalWrite(t2,HIGH);
  digitalWrite(t3,LOW);
  digitalWrite(t4,HIGH);
  digitalWrite(t5,HIGH);
  digitalWrite(t6,HIGH);
  digitalWrite(t7,HIGH);
  digitalWrite(t8,HIGH);
}
void fourth(){
    digitalWrite(t1,HIGH);
  digitalWrite(t2,HIGH);
  digitalWrite(t3,HIGH);
  digitalWrite(t4,LOW);
  digitalWrite(t5,HIGH);
  digitalWrite(t6,HIGH);
  digitalWrite(t7,HIGH);
  digitalWrite(t8,HIGH);
}
void fifth(){
    digitalWrite(t1,HIGH);
  digitalWrite(t2,HIGH);
  digitalWrite(t3,HIGH);
  digitalWrite(t4,HIGH);
  digitalWrite(t5,LOW);
  digitalWrite(t6,HIGH);
  digitalWrite(t7,HIGH);
  digitalWrite(t8,HIGH);
}
void sixth(){
    digitalWrite(t1,HIGH);
  digitalWrite(t2,HIGH);
  digitalWrite(t3,HIGH);
  digitalWrite(t4,HIGH);
  digitalWrite(t5,HIGH);
  digitalWrite(t6,LOW);
  digitalWrite(t7,HIGH);
  digitalWrite(t8,HIGH);
}
void seventh(){
    digitalWrite(t1,HIGH);
  digitalWrite(t2,HIGH);
  digitalWrite(t3,HIGH);
  digitalWrite(t4,HIGH);
  digitalWrite(t5,HIGH);
  digitalWrite(t6,HIGH);
  digitalWrite(t7,LOW);
  digitalWrite(t8,HIGH);
}
void eighth() {
    digitalWrite(t1,HIGH);
  digitalWrite(t2,HIGH);
  digitalWrite(t3,HIGH);
  digitalWrite(t4,HIGH);
  digitalWrite(t5,HIGH);
  digitalWrite(t6,HIGH);
  digitalWrite(t7,HIGH);
  digitalWrite(t8,LOW);
}

void Clear(){
     digitalWrite(A,  LOW);
  digitalWrite(B,LOW);
  digitalWrite(C,LOW);
  digitalWrite(D,LOW);
  digitalWrite(E,LOW);
  digitalWrite(F,LOW);
  digitalWrite(G,LOW);
}
void Clears(){
      digitalWrite(t1,HIGH);
  digitalWrite(t2,HIGH);
  digitalWrite(t3,HIGH);
  digitalWrite(t4,HIGH);
  digitalWrite(t5,HIGH);
  digitalWrite(t6,HIGH);
  digitalWrite(t7,HIGH);
}



void ECE()
{
   third();
   EE();
  delay(0.1);
  Clear();
   fourth();
  CC();
  delay(0.1);
  Clear();
   fifth();
  EE();
  delay(0.1);
  Clear();
}


  
  


   
  
 void loop()
 {

   
  ECE();
  Clear();
  
  CCC();   // i am unable to change it to CCC , please tell me how .
  Clear();
  
  

 
 
//school();
//Clear();
  
 
  
 }

You should put your code in a code 'box' on the screen. Use the # tool in the menu when you post.

I don't see a CCC function? Have you posted all your code.

marco_c:
You should put your code in a code 'box' on the screen. Use the # tool in the menu when you post.

I don't see a CCC function? Have you posted all your code.

Sorry, i didnt add in the CCC function. I added last minute to show u all that if i change to CCC, it is not working.

lets say AA(); . how to change from ECE, to AA?

You have no delays in the display of the letters.

Let's say that you display AA and then BB immediately afterwards. What you will see is BB because the change is so fast your eye does not perceive that AA was ever there. Also remember that at the end of loop() you can imagine that it immediately starts at the top again, so in the example you have all you will ever see is ECE (because you have a delay there) and CCC (if it existed) would immediately be replaced by ECE (or Clear in your case).

yeah, i noticed it. So how do i show AA for a time then change to BB ? by putting a delay in between or another way?

void loop()
AA();
delay(1000);
BB();
delay(1000);
}

Clear is not needed in between because you set all the pins.

Also your delay(0.1) is the same as delay(0). I am surprised that it compiles, as delay expects an integer value.

That code is very long winded. You need to learn how to use arrays. See:-
http://www.thebox.myzen.co.uk/Tutorial/Arrays.html

marco_c:

void loop()

AA();
delay(1000);
BB();
delay(1000);
}




Clear is not needed in between because you set all the pins.

Also your delay(0.1) is the same as delay(0). I am surprised that it compiles, as delay expects an integer value.

hi, sorry. Now i know how to change from AA to BB in one segment. But i wan to change the whole segment like A,B,C,D,E to E,D,C,B,A . any ideas?

any ideas?

Well you could try and read that link and try to understand it.
In that way you might start asking questions using the words that the rest of the world uses to describe things. For example:-

Now i know how to change from AA to BB in one segment.

Glad you know because I haven't got a clue as to what you are on about.

Basically you are going about it all wrong. You need to have an area of memory ( that will be an array ) that contains the bit pattern you want to display. A function that displays that bit pattern at a regular rate, and then all you need to do is to change the bit pattern in the array and that changes what you display.

What part of

You should put your code in a code 'box' on the screen. Use the # tool in the menu when you post.

do you not understand? You can modify that post, highlight the code and hit the # icon, then save. At least it will show you are paying attention to some of what we are saying.

Sorry, i changed the code box. The link is hard to understand, i dont wish to display numbers but alphabets.

What you wish to display is irrelevant it all works the same.

The link describes the concepts you need to use. If you can't understand it then you are not ready to do this project. Spend some more time doing tutorials and trying to understand them. Or ask specifically about what you don't understand.

Grumpy_Mike:
What you wish to display is irrelevant it all works the same.

The link describes the concepts you need to use. If you can't understand it then you are not ready to do this project. Spend some more time doing tutorials and trying to understand them. Or ask specifically about what you don't understand.

About the mask and pattern things. how does the mask work?

And

void display7(int num){
int mask = 1;
  for(int i=0; i<7; i++){
   if((mask & sevenCode[num]) == 0) digitalWrite(pins[i], LOW); else digitalWrite(pins[i], HIGH);
   mask = mask << 1;
  }
}

What will be outcome of the display here? what will be display?
Sorry for asking so much

Mask is a byte where only one bit is on. It starts as binary 00000001 then 00000010 then 00000100 etc as it goes thru the loop. Look up what the << operator does.

This mask is then logically anded with the bit pattern that describes which segments are supposed to be on (in the sevencode array). If the result is zero the output pin is turned off (because the bit in sevencode was off), if not it is turned on.

The display will show the segments of the 7 segment display on that were encoded in the array for the dispaly element indexed by the num parameter to the function. The array will usually encode segments a thru g in a logical sequence.

This is a very standard way of doing this. Most other schemes also include the dp for the display as one of the bit of the encoding byte as the 7 segments and the dp neatly fit in an 8 bit byte.

What will be outcome of the display here? what will be display?

What will be displayed is the bit pattern contained in the array sevenCode with an index number of the value of the variable num.
Normally this would correspond to logic ones for the segments you want to be on and zeros for those off.
This will display what ever bit pattern you have set Up in the array, normally this will be what segments need to be on to display the number num, but it could be any pattern.

Sorry for asking so much

No problem with that, it is not listening to the answers that can get annoying.