Besoin d'aide shield tick tock programme

Bonjour, moi et ma classe de terminal sti2d sommes actuellement en mini-projet pour préparer le projet du bac. Mon mini projet consiste à utiliser le shield tick tock et d’autre choses pour simuler une course de ski avec un chronomètre sur le shield tick tock ect je m’occupe de la partie code donc le côté montage relié le shield ext ne me concerne pas. J’ai donc sur mon shield tick tock en bas 3 boutons, celui du milieu (key_up) me sert a lancer mon chronomètre et ce que je cherche c’est mettre un point après disp[2] qui sépare les seconde des millisecondes et je cherche aussi a faire que quand j’appuie sur le bouton a droite (key_down) le chronomètre se met en pause et donc fige le chronomètre.

Voici mon code actuel:

#define DEBUG 1//comment out if you don't need debug information
//-------pin definition of keys---------------//
#define KEY_UP 10
#define KEY_DOWN 9
//-------pin definition of the buzzer--------//
#define ALARM_BUZZER 6
#include "TM1636.h"
//--Declare a TM1636 Class object that control the 4-digit display--//
TM1636 tm1636(7,8);

int tempo = 200;
int tempo2 = 800;
int tone2 = 400;

/*play a tone, the larger the tone is, the lower the frequency becomes*/

void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
  
  digitalWrite(ALARM_BUZZER, HIGH);
  delayMicroseconds(tone);
  digitalWrite(ALARM_BUZZER, LOW);
  delayMicroseconds(tone);
}
}
boolean demarrage=true;
unsigned long debut;
void setup() 
{
tm1636.init();
#ifdef DEBUG
Serial.begin(9600);
#endif
init_pins();
millis();
}

void loop() {

if(demarrage==true){
  
  demarrage=false;
}
Serial.print("debut=");
Serial.println(debut);

Serial.print("millis=");
Serial.println(millis());

int8_t disp[4]= {0,0,0,0};
tm1636.display(disp);
static int tone = 1000;
int16_t key_pressed = scanKey();
if(KEY_UP == key_pressed) { /*Every time the menu key pressed, it will raise the pitch of the */ /*buzzer sound. */
if(tone > 100)
tone -= 100;
playTone(tone,tempo);
 delay(700);
 playTone(tone,tempo);
 delay(700);
 playTone(tone,tempo);
 delay(700);
 analogWrite(ALARM_BUZZER, tone2);
 debut=millis();
 chrono();

}

else if(KEY_DOWN == key_pressed)
{
/*Every time the menu key pressed, it will lower the pitch of the */
/*buzzer sound. */
if(tone < 2000)
tone += 300;
playTone(tone,tempo);    
#ifdef DEBUG//output debug message
Serial.print("tone");
Serial.println(tone);
#endif
}
/*if a key has been pressed, wait for extra 200ms*/
if(key_pressed > 0)delay(200);
}



void chrono()
{
// delay(800);
// digitalWrite(ALARM_BUZZER,LOW); 
int8_t NumTab[] = {1,2,3,4,5,6,7,8,9};
int8_t table_length;
table_length = sizeof(NumTab);//get the length of the number table: NumTab
int8_t disp[3];//store the index of the 4 digit to display. 
unsigned char digit_index = 0;
unsigned char starting_index = 0;//starting index of NumTab
disp[3]=0;
disp[2]=0;
disp[1]=0;
disp[0]=0;
while(1)
{
  digit_index = starting_index;
  starting_index ++;
  if(starting_index == table_length) 
  {
    starting_index = 1;//start again
  }
  for(unsigned char BitSelect = 0;BitSelect < 4;BitSelect ++)
  {
 
    disp[3] = NumTab[digit_index];
    digit_index ++;
    if(digit_index == table_length) digit_index = 0;
    
  }
 if(disp[3] == 9) 
 {
    disp[2] = disp[2]+1; 
  }
 
  if(disp[2] == 10) 
 {
    disp[2]= 0;
    disp[1] = disp[1]+1;
 }

 if(disp[1] == 10)
 {
  disp[1] = 0;
  disp[0] = disp[0]+1;
 
 }


  if (millis()-debut>800) {
 digitalWrite(ALARM_BUZZER,LOW);
 }

 

tm1636.display(disp);//display on the 4-digit display.
  delay(100);//display 4-digit number for 100ms and then it will change.

}
}





























/* Ne pas toucher ce qui a en dessous ceci*/
/*Initialization for the keys and the buzzer*/
void init_pins()
{
/*K1 and K2 are set to be input pins*/
pinMode(KEY_UP, INPUT);
digitalWrite(KEY_UP, HIGH);
pinMode(KEY_DOWN, INPUT);
digitalWrite(KEY_DOWN, HIGH);
/*The buzzer is set to be output pin*/
pinMode(ALARM_BUZZER, OUTPUT);
digitalWrite(ALARM_BUZZER, LOW);

}
/*Scan keys and get to know which one is pressed*/
/*Return: if no key is pressed, return -1.*/
int16_t scanKey()
{
int16_t pin_number = -1;//define non-existent pin number
if(digitalRead(KEY_UP) == LOW)
{
delay(20);
if(digitalRead(KEY_UP) == LOW)//validate a press that outlasts 20ms
{
pin_number = KEY_UP;
}
#ifdef DEBUG
Serial.println("KEY_UP is pressed");
#endif
}
else if(digitalRead(KEY_DOWN) == LOW)
{
delay(20);
if(digitalRead(KEY_DOWN) == LOW)
{
pin_number = KEY_DOWN;
}
#ifdef DEBUG
Serial.println("KEY_DOWN is pressed");
#endif
}
return pin_number;
}

A lire d'urgence si tu veux avoir des réponses: