int pot = A5;
int valpot, mil, cen, dez, uni, temp = 0;
int tempo = 25;

const int Pinos[12] = { 2, 3, 4, 5, 6, 7, 8,9, 10,11,12,13 };
  const byte Numeros[10] =
 {
   0x3F, //0  0XC0
   0x06, //1 0xF9
   0x5B, //2 0XA4
   0x4F, //3 0XB0
   0x66, //4 0X99
   0x6D, //5 0X92
   0x7D, //6 0X82
   0x07, //7 0XF8
   0x7F, //8 0X80
   0x6F, //9 0X90
   };
void setup()
 {
  Serial.begin(9600);
   for(int i = 0; i < 12; i++)
     {
       pinMode(Pinos[i], OUTPUT);
     }
 }
void escreveDisplay(int num)
 {
   byte numBit = Numeros[num];
     for (int i = 0; i < 7; i++)
     {
        int bit = bitRead(numBit, i);
        digitalWrite(Pinos[i], bit);
     }
 }
void loop()
 {
  

  //Leitura do potenciômetro
  valpot = analogRead(pot);
   Serial.print("valpot = ");
  Serial.println(valpot);
  
  // mostrar milhar
   mil = valpot/1000;
  Serial.print("milhar = ");
  Serial.println(mil);
  
  // mostrar centena
  cen = (valpot/100)%10;
  Serial.print("centena = ");
  Serial.println(cen);
  
  // mostrar dezena
  dez = (valpot/10)%10;
  Serial.print("dezena = ");
  Serial.println(dez);
 
  // mostrar unidade
  uni = valpot%10;
   Serial.print("unidade = ");
  Serial.println(uni);
   
  // aciona o display unidade
       escreveDisplay(uni);
  		digitalWrite(10,0);
  		digitalWrite(11,1);
  		digitalWrite(12,1);
  		digitalWrite(13,1);
    
           delay(tempo);

 digitalWrite(10,1);
 digitalWrite(11,1);
 digitalWrite(12,1);
 digitalWrite(13,1); 


  // aciona o display dezena
        escreveDisplay(dez);
  		digitalWrite(10,1);
  		digitalWrite(11,0);
  		digitalWrite(12,1);
        digitalWrite(13,1);
        
           delay(tempo);

 digitalWrite(10,1);
 digitalWrite(11,1);
 digitalWrite(12,1);
 digitalWrite(13,1);
 

  // aciona o display centena
        escreveDisplay(cen);
  		digitalWrite(10,1);
  		digitalWrite(11,1);
  		digitalWrite(12,0);
        digitalWrite(13,1);
           delay(tempo);
  
 digitalWrite(10,1);
 digitalWrite(11,1);
 digitalWrite(12,1);
 digitalWrite(13,1);

   // aciona o display milhar
        escreveDisplay(mil);
  		digitalWrite(10,1);
  		digitalWrite(11,1);
  		digitalWrite(12,1);
        digitalWrite(13,0);
           delay(tempo);

            digitalWrite(10,1);
 digitalWrite(11,1);
 digitalWrite(12,1);
 digitalWrite(13,1);

  
 }