Hi there !

Please I need your help !

I would like to run a two timer ( TIME 1 and TIME 2) STOPWATCH on a single LCD (16/2) .

It should have a different sensor/button to stop one of the timer while the other continue to run .

I tried modifying the sketch I posted but till now I cannot stop separately each timer . When I give the input with a button , it stops both timers.

Any way to solve the problem .

Any advice is appreciated .



contasecondi_ARDUINO.ino (3.54 KB)

Can you inline your code, using code tags? That will be easier to read.

When you use 3 buttons, and 3 variables, the code should do this: When any button is pressed, the current time is copied into the associated variable. The first button will store the start time, the other buttons the stop times. The time elapsed is the difference between the individual stop and common start time.

Ok Sir,

This is the code …

#include <LiquidCrystal.h>               

int m,s,l;                               
int mu=0,md=0,su=0,sd=0,lu=0,ld=0,lc=0;
int button;
int before;
int after; 
long int time, beginning;

int ma,sa,la;                               
int mua=0,mda=0,sua=0,sda=0,lua=0,lda=0,lca=0;
int buttona;
int prima;
int dopo; 
long int timea, beginninga;

LiquidCrystal lcd (12, 11, 5, 4, 3, 2);    

void setup() {
   lcd.begin(16, 2);                     
  lcd.setCursor(4, 1);                  
  lcd.print ("00:00:000");
  pinMode(6, INPUT);                     
  pinMode(7, INPUT);                     
  pinMode(8, INPUT);
  dopo = HIGH;


void loop() {
     after = digitalRead(6);                 
  if(after ==HIGH &&  before == LOW){         

    before = after ;     
    buttona = 0;
    button = 0;     
    while (button == 0 && buttona == 0){                  

            lcd.setCursor(4, 0);               
            lcd.setCursor(4, 1);              
          after = digitalRead(8);            
      if(after ==HIGH && before==LOW){     
        //el sensor
        buttona =1;                    
    lcd.clear ();
    lcd.setCursor(4, 1);                
        //Escribimos 00:00:000 (Ponemos el cronometro a 0)
    lcd.setCursor(4, 0);                 
// }
   before = after ;                     
  before = after ;                          

I'd suggest that you format your code, then you'll better see the ranges of conditions and loops. It also might help you when you move the calculation and display code into subroutines, so that the control flow becomes more obvious in loop().

I suspect that you should add and use beforeA and afterA for the second button.

Have you read Doing multiple things at once?