Stopwatch using a 32 x 16 LED Matrix. DMD P10 RED single colorNEED HELP!

Can you give me xample...to my sketch that I made

Haha..Im not pro..Im not made it

You code is not suitable for the stopwatch.
Stopwatch must not use delay() functions.

Again, are you call the Result() from the function itself?

this is an infinite recursion which will cause the program to hang.

So I don't understand, what you meant:

I try to analyze the sketch and try it for dot matrix displays

Stay in Result() until I push reset

Reset on board arduino

Did you try it? :slight_smile:
This code won't "stay in...", it will hang the board almost immediately.

If you want to stay in the function - use infinite while loop:

while (1);

Do not use recursion if you don't understand it.


Its work normali

No, it is impossible.
Perhaps you didn't try to run the code to the second lap.

Do not use recursion if you don't understand it.


#include <Wire.h>
#include <SPI.h>        //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h>        //Library DMD yang menyediakan fungsi penampilan teks, gambar dsb
#include <TimerOne.h>   //Library peripheral Timer1 untuk menjalankan prosedur pindai panel DMD
#include <Time.h>     //Library waktu yang menyediakan tipe data, struktur, dan obyek waktu

#include "Mono5x7.h"




#define DISPLAY_COLUMN_COUNT  3
#define DISPLAY_ROW_COUNT     2

#define PIXELS_PER_COLUMN  32
#define PIXELS_PER_ROW    16

DMD dmd(DISPLAY_COLUMN_COUNT, DISPLAY_ROW_COUNT);
unsigned char show = 0;

char lineBuff[20];
char lineBuff2[20];

int lineA;       
int Start;

int minutes;
int seconds;
int cents;
long start_time = 0;



void ScanDMD()
{
  dmd.scanDisplayBySPI();
}


void setup(void)
{

pinMode(2,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(4,INPUT_PULLUP);
  dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
  Serial.begin(9600);
   //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
  Timer1.initialize( 1000 );           //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
  Timer1.attachInterrupt( ScanDMD );   //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI() 
  //clear/init the DMD pixels held in RAM
  dmd.clearScreen( true );
}


void loop()
{
  lineA = digitalRead(2);
  if((lineA == 0)&&(Start == 0)){
  delay(200);
  Start = 1;
  start_time = millis(); 
}  
  Chronometer();
  Pause();
  Laptime();
 
}



void Chronometer(void){  
if(Start == 1){
minutes = (millis() - start_time) / 60000;
seconds = ((millis() - start_time) / 1000) % 60;
cents = ((millis() - start_time) / 10) % 100;
}
//===========================================================================  
sprintf(lineBuff, "%02d:%02d.%02d",minutes,seconds,cents);
dmd.selectFont(Mono5x7);
dmd.drawString( 1,  2, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL); 
//===========================================================================
}

void Pause(void){
if(digitalRead(4) == HIGH)
return;
else if (digitalRead(4) == LOW){
while(digitalRead(2)  == HIGH) { 
if (digitalRead(3) == LOW)
Laptime(); 
  }
}
}

void Split(void){
if(digitalRead(3) == HIGH)
return;
else if (digitalRead(3) == LOW){
Laptime();
}
}


void Laptime(void){
if(digitalRead(3) == HIGH)
return;
else if (digitalRead(3) == LOW){
sprintf(lineBuff, "%02d:%02d.%02d",minutes,seconds,cents);
dmd.selectFont(Mono5x7);
dmd.drawString( 1,  10, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);
  while(digitalRead(3)  == LOW) {};
}
}
![IMG_20230525_233621|375x500](upload://3ZXxqDp7sakR9XP9EsP0HX0DoeK.jpeg)

how do you add a split lap, second, third and so on?

In the Pause() procedure, there is no point in calling Laptime() in a loop:

the time inside this procedure is not updated, so the stopwatch display will stand still. And if so, it means that it is enough to display the data on the screen once

Yes, that's true. Even the time doesn't stop properly when paused, only the display stops

What should I do?

It is because the millis() doesn't stop when you enter to the Pause() function

how do i pause of millis?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.