TLC5940 multiplexing clock

So i bought a 6 digit 16 segment display common anode, and i managed to get the a clock working with 1 TLC5940 for the cathodes and 6 arduino pins for the anodes.
My problem here is that in the first digit appear the ones of the seconds, the second digit the tens of the hour, the third digit the ones of the hour, and so on.
I dont know what the problem is with the code, so if anyone could help me...
My schematic is like those found in the net

#include "Tlc5940.h"
#include <Wire.h>
#include "RTClib.h"

RTC_DS3231 rtc;

int digitpins[6] = {7, 6, 5, 4, 2, 8};
int tempo[6];

int numeros[36][16] = {
  /*a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p*/
  {1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0}, // 0{B00000000, B01101111}
  {1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0}, // 1{B11001111, B11111111}
  {1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1}, // 2{B00010001, B11011011}
  {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1}, // 3{B00000011, B11011011}
  {0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1}, // 4{B11001110, B11011011}
  {1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1}, // 5{B00100010, B11011011}
  {1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, // 6{B00100000, B11011011}
  {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0}, // 7{B00111111, B10110111}
  {1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, // 8{B00000000, B11011011}
  {1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1}, // 9{B00000010, B11011011}
  {1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, // A
  {1, 1, 1, 1, 1, 1, 0, 0,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0, 0, 0}, // U
  {0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0}, // V
  {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0}, // W
  {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0}, // X
  {0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1}, // Y
  {1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0}, // Z
};

void setup() {
  Tlc.init();
  //----------------------------
#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif

  Serial.begin(9600);

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
  //----------------------------

  for (int i = 0; i < 6; i++) {
    pinMode(digitpins[i], OUTPUT);
    digitalWrite(digitpins[i], LOW);
  }
}
////------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void loop() {
  for (int i = 0; i < 6; i++) {
    gettime();
        for (int j = 0; j < 16; j++) {
      if (numeros[tempo[i]][j] == 1) {
        Tlc.set(j, 4095);
      }
      else {
        Tlc.set(j, 0);
      }
    }
    digitalWrite(digitpins[i], HIGH);
    delay(1);
    Tlc.update();
    digitalWrite(digitpins[i], LOW);
    Tlc.clear();
  }

}
////------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void gettime() {
  DateTime now = rtc.now();
  tempo[0] = (now.hour() / 10) % 10;
  tempo[1] = now.hour() % 10;
  tempo[2] = (now.minute() / 10) % 10;
  tempo[3] = now.minute() % 10;
  tempo[4] = (now.second() / 10) % 10;
  tempo[5] = now.second() % 10;
}

Try changing the order of your digitpins{}.

Or show a shematic of how you have it all hooked up.

Without a schematic the code alone can not tell you what is wrong.


The tlc output pins go to the cathodes of the display, and the arduino pins go to the anodes.
Now im not in my pc, but i can leave here a full schematic if you guys want

OK but a schematic would have those LEDs labeled with the seven segment display number and the segment name ( a to g ). Given the problem is that the wrong numbers are lighting up it is is sort of vital information to see if your software or wiring is wrong. You also need a 0.1uF ceramic between the power and ground of each TLC5940.

I think the problem is with the code. Because when i have just one digit working (and the correspondent anode wired directly to vcc) and the code turning the numbers from 0 to 9, and A to Z, it displays the correct numbers and alphabet.

I didnt know that i needed a capacitor. I will see if i have one

Yes but in order to understand what is wrong with the software we need to know how your circuit is wired.
You said in the first post:-

So i bought a 6 digit 16 segment display common anode, and i managed to get the a clock working with 1 TLC5940 for the cathodes and 6 arduino pins for the anodes.

That dose not square with the diagram you posted.

I know, that is just for testing the numbers and the alphabet cycling.
The diagram i posted is one found in the net, for just having an idea, i will post the full schematic in a couple of hours

Why have you abandoned your previous thread here? You did not respond to my last suggested code change. Your code is still wrong, and this explains why your digits are in the wrong place. I have suggested how to fix it but you ignore my attempts to help.

Sorry Paul, i forgot to reply.
And, no that code doesnt work.

////------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void loop() {
  for (int i = 0; i < 6; i++) {
    gettime();
    for (int j = 0; j < 16; j++) {
      if (numeros[tempo[i]][j] == 1) {
        Tlc.set(j, 4095);
      }
      else {
        Tlc.set(j, 0);
      }
    }
    Tlc.update();
    delay(1);
    digitalWrite(digitpins[i], HIGH);
    delay(1);
    digitalWrite(digitpins[i], LOW);
  }
}

This code work, but looks like i need those delays there, otherwise the code doesnt work. I dont know why this work like this.
You were close Paul, thank you