Need help!!!

I built a 7-segment display, hooked it up and all characters work, but I am having a little trouble. My display has two 7-segments side by side, so I can display from 0 to 99. I want to be able to use a pot and map the value from 0 to 99 two show the val on the display. My question is, if my pot val is 48, is there a way that i can split the number into two numbers which would be 4 and 8 so that that i can just assign the 4 to the first 7-segment and 8 to the seconed.

I cant seem to get it going, I just need to be able to maybe multiplex the two displays? any other sugestions on how to do this?

yes, yes, yes, no. I still need to be able to do that part.

To be honest Right now all i did was make a code to drive the first decimal place from 0 to 9 using the pot and I got it going very easily. this is the code I used.

int a1 = 2;
int b1 = 13;
int c1 = 10;
int d1 = 6;
int e1 = 5;
int f1 = 3;
int g1 = 4;
int a2 = 17;
int b2 = 14;
int c2 = 16;
int d2 = 15;
int e2 = 12;
int f2 = 8;
int g2 = 9;
int t = 1000;
int pot;
void setup(){
  Serial.begin(9600);
  pinMode(a1, OUTPUT);
  pinMode(b1, OUTPUT);
  pinMode(c1, OUTPUT);
  pinMode(d1, OUTPUT);
  pinMode(e1, OUTPUT);
  pinMode(f1, OUTPUT);
  pinMode(g1, OUTPUT);
  pinMode(a2, OUTPUT);
  pinMode(b2, OUTPUT);
  pinMode(c2, OUTPUT);
  pinMode(d2, OUTPUT);
  pinMode(e2, OUTPUT);
  pinMode(f2, OUTPUT);
  pinMode(g2, OUTPUT);

}
void loop(){
  pot = analogRead(4);
  pot = map(pot, 0, 1023, 0, 9);
  Serial.println(pot, DEC);

  if(pot == 0){
    bzero();
  }
  if(pot == 1){
    bone();
  }
  if(pot == 2){
    btwo();
  }
  if(pot == 3){
    bthree();
  }
  if(pot == 4){
    bfour();
  }
  if(pot == 5){
    bfive();
  }
  if(pot == 6){
    bsix();
  }
  if(pot == 7){
    bseven();
  }
  if(pot == 8){
    beight();
  }
  if(pot == 9){
    bnine();
  }

}
void bzero(){
  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, HIGH);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, LOW);
}
void bone(){
  digitalWrite(a2, LOW);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, LOW);
  digitalWrite(e2, LOW);
  digitalWrite(f2, LOW);
  digitalWrite(g2, LOW);
}
void btwo(){
 digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, LOW);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, HIGH);
  digitalWrite(f2, LOW);
  digitalWrite(g2, HIGH);
}
void bthree(){
  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, LOW);
  digitalWrite(f2, LOW);
  digitalWrite(g2, HIGH);
}
void bfour(){
  digitalWrite(a2, LOW);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, LOW);
  digitalWrite(e2, LOW);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
}
void bfive(){
  digitalWrite(a2, HIGH);
  digitalWrite(b2, LOW);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, LOW);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
}
void bsix(){
  digitalWrite(a2, HIGH);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
  digitalWrite(e2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(c2, HIGH);
}
void bseven(){
  digitalWrite(a2, HIGH);
  digitalWrite(b2, LOW);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, HIGH);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
}
void beight(){
  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, HIGH);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
}
void bnine(){
  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, LOW);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
}
void alloff(){
  digitalWrite(a2, LOW);
  digitalWrite(b2, LOW);
  digitalWrite(c2, LOW);
  digitalWrite(d2, LOW);
  digitalWrite(e2, LOW);
  digitalWrite(f2, LOW);
  digitalWrite(g2, LOW);
}

In the code a1 is the first display and it drives the top middle led just as a is on all 7-segments and when you get to a2 its the second display top middle and so on. Ill admit the code is a mess but it works. now that Ive done this part I need to use both of the displays, I dont know how to do this. Can you give me an example?

It is a very long winded naive way of writing code. However take this bit:- pot = map(pot, 0, 1023, 0, 9); Serial.println(pot, DEC); and change it to:-

potRaw = map(pot, 0, 1023, 0, 9); Serial.println(pot, DEC); pot = potRaw % 10; // modulo operator ... all your code driving the first digit then do pot = potRaw / 10; ... all your code again but now driving the second digit

That will do it. Then learn how to write code properly using arrays.

potRaw = map(pot, 0, 1023, 0, 9); Serial.println(pot, DEC); pot = potRaw % 10; // modulo operator ... all your code driving the first digit then do pot = potRaw / 10; ... all your code again but now driving the second digit

potRaw will be a one digit number...

Probably want to map to 0, 99 to get a two digit number.

potRaw will be a one digit number...

Yes well spotted I didn't see the map function. Just need to change it to:- potRaw = map(pot, 0, 1023, 0, 99);

Rewrote the code to make it do only the first digit, but had a few problems.

This is the new code*

int a1 = 2;
int b1 = 13;
int c1 = 10;
int d1 = 6;
int e1 = 5;
int f1 = 3;
int g1 = 4;
int a2 = 17;
int b2 = 14;
int c2 = 16;
int d2 = 15;
int e2 = 12;
int f2 = 8;
int g2 = 9;
int t = 1000;
byte potRaw;
int pot;
void setup(){
  Serial.begin(9600);
  pinMode(a1, OUTPUT);
  pinMode(b1, OUTPUT);
  pinMode(c1, OUTPUT);
  pinMode(d1, OUTPUT);
  pinMode(e1, OUTPUT);
  pinMode(f1, OUTPUT);
  pinMode(g1, OUTPUT);
  pinMode(a2, OUTPUT);
  pinMode(b2, OUTPUT);
  pinMode(c2, OUTPUT);
  pinMode(d2, OUTPUT);
  pinMode(e2, OUTPUT);
  pinMode(f2, OUTPUT);
  pinMode(g2, OUTPUT);

}
void loop(){
  potRaw = analogRead(4);
  potRaw = map(potRaw, 0, 1023, 0, 99);
  pot = potRaw % 10;

  if(pot == 0){
    bzero();
  }
  if(pot == 1){
    bone();
  }
  if(pot == 2){
    btwo();
  }
  if(pot == 3){
    bthree();
  }
  if(pot == 4){
    bfour();
  }
  if(pot == 5){
    bfive();
  }
  if(pot == 6){
    bsix();
  }
  if(pot == 7){
    bseven();
  }
  if(pot == 8){
    beight();
  }
  if(pot == 9){
    bnine();
  }
  if(pot == 10){
    bten();
  }

  pot = potRaw / 10;


}
void bzero(){
  digitalWrite(a1, HIGH);
  digitalWrite(b1, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(d1, HIGH);
  digitalWrite(e1, HIGH);
  digitalWrite(f1, HIGH);
  digitalWrite(g1, LOW);

  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, HIGH);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, LOW);
}
void bone(){
  digitalWrite(a1, HIGH);
  digitalWrite(b1, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(d1, HIGH);
  digitalWrite(e1, HIGH);
  digitalWrite(f1, HIGH);
  digitalWrite(g1, LOW);

  digitalWrite(a2, LOW);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, LOW);
  digitalWrite(e2, LOW);
  digitalWrite(f2, LOW);
  digitalWrite(g2, LOW);
}
void btwo(){
  digitalWrite(a1, HIGH);
  digitalWrite(b1, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(d1, HIGH);
  digitalWrite(e1, HIGH);
  digitalWrite(f1, HIGH);
  digitalWrite(g1, LOW);

  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, LOW);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, HIGH);
  digitalWrite(f2, LOW);
  digitalWrite(g2, HIGH);
}
void bthree(){
  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, LOW);
  digitalWrite(f2, LOW);
  digitalWrite(g2, HIGH);
}
void bfour(){
  digitalWrite(a1, HIGH);
  digitalWrite(b1, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(d1, HIGH);
  digitalWrite(e1, HIGH);
  digitalWrite(f1, HIGH);
  digitalWrite(g1, LOW);

  digitalWrite(a2, LOW);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, LOW);
  digitalWrite(e2, LOW);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
}
void bfive(){
  digitalWrite(a1, HIGH);
  digitalWrite(b1, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(d1, HIGH);
  digitalWrite(e1, HIGH);
  digitalWrite(f1, HIGH);
  digitalWrite(g1, LOW);

  digitalWrite(a2, HIGH);
  digitalWrite(b2, LOW);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, LOW);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
}
void bsix(){
  digitalWrite(a1, HIGH);
  digitalWrite(b1, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(d1, HIGH);
  digitalWrite(e1, HIGH);
  digitalWrite(f1, HIGH);
  digitalWrite(g1, LOW);

  digitalWrite(a2, HIGH);
  digitalWrite(b2, LOW);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, HIGH);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
}
void bseven(){
  digitalWrite(a1, HIGH);
  digitalWrite(b1, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(d1, HIGH);
  digitalWrite(e1, HIGH);
  digitalWrite(f1, HIGH);
  digitalWrite(g1, LOW);

  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, LOW);
  digitalWrite(e2, LOW);
  digitalWrite(f2, LOW);
  digitalWrite(g2, LOW);
}
void beight(){
  digitalWrite(a1, HIGH);
  digitalWrite(b1, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(d1, HIGH);
  digitalWrite(e1, HIGH);
  digitalWrite(f1, HIGH);
  digitalWrite(g1, LOW);

  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, HIGH);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
}
void bnine(){
  digitalWrite(a1, HIGH);
  digitalWrite(b1, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(d1, HIGH);
  digitalWrite(e1, HIGH);
  digitalWrite(f1, HIGH);
  digitalWrite(g1, LOW);

  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, LOW);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, HIGH);
}
void bten(){
  digitalWrite(a2, HIGH);
  digitalWrite(b2, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(e2, HIGH);
  digitalWrite(f2, HIGH);
  digitalWrite(g2, LOW);

  digitalWrite(a1, LOW);
  digitalWrite(b1, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(d1, LOW);
  digitalWrite(e1, LOW);
  digitalWrite(f1, LOW);
  digitalWrite(g1, LOW);
}
void alloff(){
  digitalWrite(a2, LOW);
  digitalWrite(b2, LOW);
  digitalWrite(c2, LOW);
  digitalWrite(d2, LOW);
  digitalWrite(e2, LOW);
  digitalWrite(f2, LOW);
  digitalWrite(g2, LOW);
}

This code counts from 0 to 9, 9 times on the first digit but after the last nine it keeps counting up to the next 4 it doesnt stop after the 9th nine.
http://s1013.photobucket.com/albums/af256/sdgsdfgsdf_2010/?action=view&current=IMG_0522.flv

This code counts from 0 to 9, 9 times on the first digit but after the last nine it keeps counting up to the next 4 it doesnt stop after the 9th nine.

Yes that is what you wrote. You didn't do what I said. You just did :- pot = potRaw / 10; at the end of the loop and then you repeat writing the first digit again. You should follow the pot = potRaw / 10; by all the code written again but addressing the most significant digit display. As I said it is not the right way to do it but it will work.