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

I have adapted a sketch for a stopwatch using an 16 x 2 LCD display witout I2C but would like something bigger. I thought about a 32 x 16 DMD P10 Red single color but can't find a sketch for a stopwatch. Has anyone done this already, or can anyone offer any help as to how to display a stopwatch on an LED matrix.

What is your problem?

This is my sketch

#include <LiquidCrystal.h>
//PIN 5 R/W to Ground, for writing
//LCD Mode : 4 data pin
//Functions: Start, stop, saving up to 4 partial time in memory.
//10 millis = 1 hundredth of a second. The chronometer measures hour, minutes, seconds, and hundredths of a second.

//Buttons with internal Pullup, so if they get pressed we get LOW
const int start = 8;  //Start the stopwatch
const int pausa = 9;  //Pausa
const int partial = 10;  //Save a partial
const int scroll_partial = 11;  //If paused, check the 4 last saved partial 
int x = 0; //Variable to manage the loop

//LCD
int lcdclear = 0; //this to variables are needed for managing
int Display = 0; //the display, to clear and print

//chronometer
int cents = 0;
int seconds = 0;  
int minutes = 0;
int hours = 0;
const int interval = 10; //Every 10 milliseconds i increase  1 cent
unsigned long previousMillis = 0;
int c1, c2, s1, s2, m1, m2, h; //Variables used to put in the form 
                              //h:m2m1:s2s1:c2c1

//Partial: I save 4 partial, that can be seen if stopwatch is stopped
int partial2[7]; //penultimate partial (The one that stays in Old). The last partial stays in New:
int partial3[7]; 
int partial4[7]; 
int scrolling = 0; //Used to scroll the saved partial times


LiquidCrystal lcd(2, 3, 4, 5, 6, 7); // RS-Enable-D4-D5-D6-D7 in that digitalPin

void setup() {
  pinMode(start, INPUT_PULLUP); //In the schematic from right to left
  pinMode(pausa, INPUT_PULLUP);//there are start-pausa-partial-scroll_partial
  pinMode(partial, INPUT_PULLUP);
  pinMode(scroll_partial, INPUT_PULLUP);
  lcd.begin(16,2);
  lcd.print("Press start");

}

void loop() {
  if (x == 0) {  //Initially is 0
    while(digitalRead(start) == HIGH) {};  //Until i press the button, the chronometer doesn't start
  x++; //When i press the button, i go out from this cycle, x++ and i cannot return here anymore
  }
  if (lcdclear == 0){   //Condition to clear the display, used in the various functions
    lcd.clear();
    lcdclear++;
  }
  if (Display == 0){ //Also this is used to clear display
  lcd.home();
  lcd.print("Now:  ");  //With this condition, i can print "Now: " one single time, otherwise the chronometer wouldn't be precise
  Display++; 
  scrolling = 0; //When i exit from the partial menu, then if i go in the partial menu again i always get in PAR1 and PAR2
  }              
  chronometer(); //At the end of every increase, i control if stop is pressed. And also if the partial function is pressed
  pause();
  f_partial();
}

void chronometer(void){   //This function print:   "New: Actual time"
  unsigned long currentMillis = millis();  //If for the updating. If it is true, it means 1 cent of a second had passed. Update cents, minutes, seconds, hours and then i write on the lcd
  if (currentMillis - previousMillis >= interval) {  
    previousMillis = currentMillis;
    cents++;
    if (cents == 100){
      cents = 0;
      seconds++;
      if (seconds == 60) {
        seconds = 0;
        minutes++;
        if (minutes == 60){
          minutes = 0; 
          hours++;
          if (hours == 24)
            hours = 0;
          }
      }
   }
    int cent = cents;
    int sec = seconds;
    int minu = minutes; //Taking the digits separeted
    h = hours;  //For the other funcionts, so i can put hours = 0 and h still is the last value
    c1 = cent%10;
    cent /= 10;
    c2 = cent%10;
    s1 = sec%10;
    sec /= 10;
    s2 = sec%10;
    m1 = minu%10;
    minu /= 10;
    m2 = minu%10;
    lcd.setCursor(6, 0);
    lcd.print(h);
    lcd.print(':');
    lcd.print(m2);
    lcd.print(m1);
    lcd.print(':');
    lcd.print(s2);
    lcd.print(s1);
    lcd.print(':');
    lcd.print(c2);
    lcd.print(c1); 
  } 
}

void scrollPartial(void){
    while(digitalRead(scroll_partial) == LOW) {}; //Debounce, as long as i press the button the real function doesn't start
    if (scrolling == 0) { //Visualize the last 2 partials
    lcd.clear(); 
    lcd.home();
    lcd.print("PAR1:");
    lcd.setCursor(6, 0);
    lcd.print(h);
    lcd.print(':');
    lcd.print(m2);
    lcd.print(m1);
    lcd.print(':');
    lcd.print(s2);
    lcd.print(s1);
    lcd.print(':');
    lcd.print(c2);
    lcd.print(c1);
    lcd.setCursor(0, 1);
    lcd.print("PAR2:");
    lcd.setCursor(6, 1);
    lcd.print(partial2[0]);
    lcd.print(':');
    lcd.print(partial2[1]);
    lcd.print(partial2[2]);
    lcd.print(':');
    lcd.print(partial2[3]);
    lcd.print(partial2[4]);
    lcd.print(':');
    lcd.print(partial2[5]);
    lcd.print(partial2[6]); 
    Display = 0; //When i press start the display must be cleared
    lcdclear = 0; //When i press start the display must be cleared
    cents = seconds = minutes = hours  = 0;
    scrolling++;
  }
  else if (scrolling == 1){ //Visualize 3th and 4th partial
    lcd.clear();
    lcd.home();
    lcd.print("PAR3:");
    lcd.setCursor(6, 0);
    lcd.print(partial3[0]);
    lcd.print(':');
    lcd.print(partial3[1]);
    lcd.print(partial3[2]);
    lcd.print(':');
    lcd.print(partial3[3]);
    lcd.print(partial3[4]);
    lcd.print(':');
    lcd.print(partial3[5]);
    lcd.print(partial3[6]);
    lcd.setCursor(0, 1);
    lcd.print("PAR4:");
    lcd.setCursor(6, 1);
    lcd.print(partial4[0]);
    lcd.print(':');
    lcd.print(partial4[1]);
    lcd.print(partial4[2]);
    lcd.print(':');
    lcd.print(partial4[3]);
    lcd.print(partial4[4]);
    lcd.print(':');
    lcd.print(partial4[5]);
    lcd.print(partial4[6]); 
    Display = 0; //When i press start the display must be cleared
    lcdclear = 0; //When i press start the display must be cleared
    cents = seconds = minutes = hours  = 0;
    scrolling = 0;
    
  }
  
} 


void pause(void){  //If pause is pressed, i stop in this function until start doesn't get pressed again
      if (digitalRead(pausa) == HIGH) 
        return;
      else if (digitalRead(pausa) == LOW){ //Stuck in this cycle until i press start
        while(digitalRead(start) == HIGH) {  
          if (digitalRead(scroll_partial) == LOW) //If i press the button for seeing the partial, i enter in that function
            scrollPartial();    //When scrollPartial() ends, i'm still in this function, so if i press start the chronometer starts back normal
          }
    } 
}

void f_partial(void){   //If this button is pressed, i put the current value of New in Old, and a new crhonometer starts
  if (digitalRead(partial) == HIGH)
    return;
  else if (digitalRead(partial) == LOW ){ 
   lcd.clear();
   lcd.setCursor(0, 1); //The values calculated in the function chronometer can be used,  h,m,s,c
   lcd.print("Old: ");
   lcd.setCursor(6, 1);
   lcd.print(h);
   lcd.print(':');
   lcd.print(m2);
   lcd.print(m1);
   lcd.print(':');
   lcd.print(s2);
   lcd.print(s1);
   lcd.print(':');
   lcd.print(c2);
   lcd.print(c1);   //When i come here, i've got the old values for h,m,s,c,                       i save it in the partial array
   Display = 0;   //The new is written again 
   cents = 0;
   seconds = 0;
   minutes = 0;
   hours = 0;

   partial4[0] = partial3[0]; //Partial4[] is updated with the old partial3[]
   partial4[1] = partial3[1];
   partial4[2] = partial3[2];
   partial4[3] = partial3[3];
   partial4[4] = partial3[4];
   partial4[5] = partial3[5];
   partial4[6] = partial3[6];
   
     
   partial3[0] = partial2[0]; //Partial3[] is updated with the old partial2[]
   partial3[1] = partial2[1];
   partial3[2] = partial2[2];
   partial3[3] = partial2[3];
   partial3[4] = partial2[4];
   partial3[5] = partial2[5];
   partial3[6] = partial2[6];
    
   partial2[0] = h;    //Update partial2 with OLD
   partial2[1] = m2;
   partial2[2] = m1;
   partial2[3] = s2;
   partial2[4] = s1;
   partial2[5] = c2;
   partial2[6] = c1;
  
   while(digitalRead(partial) == LOW) {}; //Debounce, until i press the button i stay here
  } 
}[quote="Oniduino, post:1, topic:1104524, full:true"]
I have adapted a sketch for a stopwatch using an 16 x 2 LCD display witout I2C but would like something bigger. I thought about a *32 x 16 DMD P10 Red single color* but can't find a sketch for a stopwatch. Has anyone done this already, or can anyone offer any help as to how to display a stopwatch on an LED matrix.
[/quote]


if you are unable to ask a specific question
I'm unable to answer.

Looked up your profile. Newbee for 3 years now .
With your kind of postings you made the following impression to me:
did not yet learn basics about programming.
did not yet post a specific question.

My assumption: seems to expect to receive a ready to run code.
But is too shy to write this explicitly.

If this picture is not coming close to the truth how you are change the picture by start asking specific questions.

If this picture is coming close to the thruth how you are: change your attitude about programming then
change the picture by start asking specific questions.

Take a look into this tutorial:

Arduino Programming Course

It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.

best regards Stefan

I'm learning arduino only in my free time and not too specific. I'm sorry if I haven't progressed significantly. Therefore I need the help of a professional like you

will you help me?

I want to make a stopwatch with split time and digital lap time features for a swimming competition. DMD P10 32*16 board

depends on your OWN EFFORT
I will answer
specific questions directly related to lines of code

This is a description what you want to do. Important to write that.
Additionally you should at least
post a
specific questions directly related to lines of code

I will only answer if you

  • have made a modification of the code posted above combined with a specific question
  • posted a specific question about at least a single line of code what this line of code is doing.

I will try nek weekend

Hai Stefan :v:

I really don't really understand it but still keep trying.every week I always try to make time for my project,and I'm still struggling to translate what I mean into the arduino board.

this sketch is quite difficult for me. i still can't make split memory function into it.
will you guide me patiently :crazy_face::crazy_face:


#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 "Arial_black_16.h"
#include "Arial_Black_16_ISO_8859_1.h"
#include "Arial14.h"
#include "DejaVuSans9.h"
#include "Droid_Sans_12.h"
#include "Droid_Sans_16.h"
#include "DejaVuSansItalic9.h"
#include "Mono5x7.h"
#include "SystemFont5x7.h"
#include "SystemFont5x7.h"
#include "Font16.h"
#include "Finish16.h"
#include "font13x28.h"
#include "font13x29.h"
#include "angka13x29.h"
#include "huruf13x29.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;        //1 lap

int Start;
int Minutes;
int Seconds;
int Cents;
long start_time = 0;
int lap;



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


void setup(void)
{

pinMode(2,INPUT_PULLUP);      // push button start
  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(void)
{

//============================================
lineA = digitalRead(2);     

if((lineA == 0)&&(Start == 1)){
lap++;
delay(100);
}

//=============================================


if(lap > 2){
dmd.clearScreen( true );
sprintf(lineBuff2, "FINISH", lap);
dmd.selectFont(Mono5x7);
dmd.drawString( 10,  2, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(1000);
dmd.clearScreen( true );
Result();

}




///=========================================================

  lineA = digitalRead(2);
if((lineA == 0)&&(Start == 0)){
  delay(200);
  Start = 1;
  start_time = millis();  
}  
  


  
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( 0,  0, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL); 
sprintf(lineBuff2, "%d", lap);
dmd.selectFont(Mono5x7);
dmd.drawString( 64,  0, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);
}


void Result(){
sprintf(lineBuff,"%02d:%02d:%02d",Minutes,Seconds,Cents);
dmd.selectFont(Mono5x7);
dmd.drawString( 1,2,lineBuff,strlen(lineBuff),GRAPHICS_NORMAL); 
Result();  
}


c[quote="Oniduino, post:1, topic:1104524, full:true"]
I have adapted a sketch for a stopwatch using an 16 x 2 LCD display witout I2C but would like something bigger. I thought about a 32 x 16 DMD P10 Red single color but can't find a sketch for a stopwatch. Has anyone done this already, or can anyone offer any help as to how to display a stopwatch on an LED matrix.
[/quote]

I cannot add split lap timer function one by one lap timer

Like my generic stopwatch can save 10 split memory as same time

If you plan to make a stop watch with a digits only, why did you include all this fonts to the code???

I'm trying the gldc font creator software and making some examples

I want to add split function to my sketch but dont know how to do that.
Like my generic stopwatch can save more than 10 memory splits time

Add a button @Save@ and put the current time to the variable for using it later. If you need to store ten times - make an array with 10 elements.


My first generic stopwatch with 10 memory split

Are you who made it? And you who wrote the firmware? So you have a code to store the time splits to the memory. The code doesn't depend on type of the display, you can use the code from that stopwatch to the new one