Chronometer for modelism project !

Hi all :stuck_out_tongue:

I want to be helped please, my project is a track where is a chronometer start when a captor detect the vehicle at the beginning and stop when it arrive !

So i have made the track etc.. but i want the display to show directly via 4 digits 7 seg the time in millis, i need a help just for the part of the digit : i don't know how display the number wanted at the right place. I just want to learn how display the good number when i press the '7' for example.. After for the rest i think i try alone but a help is not rejected !! :slight_smile:

If you can help me please ! 8)

Perhaps this example will help. Segments are connected to pins 5 through 12. Digits are connected to pins 14, 2, 3, and 4.

// Digit select lines, right to left
#define DIGIT4 14  // LSD
#define DIGIT3 2
#define DIGIT2 3
#define DIGIT1 4  // MSD

// Bit maps for the seven segment display
const unsigned char Segments[] =
{
  0b11000000, // 0
  0b11001111, // 1
  0b10100100, // 2
  0b10000110, // 3
  0b10001011, // 4
  0b10010010, // 5
  0b10010000, // 6
  0b11000111, // 7
  0b10000000, // 8
  0b10000011, // 9
};


// List of digit select lines, least significant digit first
const unsigned char Digits[4] = {
  DIGIT4, DIGIT3, DIGIT2, DIGIT1};


void setup()
{
  for (int i=2; i<15; i++)
  {
    pinMode(i,OUTPUT);
    digitalWrite(i,LOW);
  }
  digitalWrite(12, HIGH);
  digitalWrite(13, HIGH);
}

void loop()
{
  // Get time since last reset
  int clock;

////////  Set 'clock' to the 4-digit integer to be displayed

  // Display each digit, right to left
  for (int i=0; i<4; i++)
  {
    
    // Peel a digit off the low end of the number
    int digit = clock % 10;
    clock /= 10;
    
    // Blank the MSD if it is zero
    if (i==3 && digit == 0)
    {
      for (int s=5; s<12; s++)
        digitalWrite(s,HIGH);
    }
    else
    {
      // Display the digit on the seven segments
      unsigned char segments = Segments[digit];
      for (int s=5; s<12; s++)
      {
        digitalWrite(s,segments & 1);
        segments >>= 1;
      }
    }

    // Turn on the digit briefly
    digitalWrite(Digits[i], HIGH);  // Select one digit
    delay(3);
    digitalWrite(Digits[i], LOW);
  }
}

thanks a lot :slight_smile: