Project showcase
Stopwatch with Arduino starter kit

Stopwatch with Arduino starter kit © GPL3+

Stopwatch with start/pause/lap/reset functions built with Arduino uno, LCD and two switches.

  • 2,740 views
  • 1 comment
  • 7 respects

Components and supplies

About this project

Build from the ground up and improve step by step:

1. learn millis() and LCD (project book project 8 and 11)

2. program to enable timming and display

3. install two switches to realize start(button 1) and reset(button 2) function

4. add stop function to button 1

5. change stop function to pause function

6. add lap&display function to button 2 when timing

7. improve the stopwatch by display timming at row 0 col 0, display lap spilts at row 0 col 1 and row 1 col 1

Code

Untitled fileArduino
 //function: stopwatch with start/stop(button 1) and reset(button 2)
//start/pause button 1 
//add lap function success!!
//improve lap function scuuess!!
 #include<LiquidCrystal.h>
 LiquidCrystal lcd(12,11,7,6,5,4);

 int ss1 = 0, ss2 = 0;
 int pss1 = 0;
 int ms=0,sec =0, minute=0;
long interval = 98;
unsigned long last=0,dur,pre=0,last2=0,dur2;
 int num_rise=0;
bool reset=0,row=0;

void timeNprint(){
    unsigned long curr = millis();
    if (curr-pre>interval){
    pre=curr;
    ms++;
      if (ms==10) {sec++;ms=0;}
      if (sec==60) {sec=0;minute++;}
    lcd.setCursor(0,0);
      if (minute<10) lcd.print("0");
    lcd.print(minute);
    lcd.print(":");
    if (sec<10) lcd.print("0");
    lcd.print(sec);
    lcd.print(":");
    lcd.print(ms);
    }
}
void printTime(){
  lcd.setCursor(9,row);
  row=!row;
      if (minute<10) lcd.print("0");
    lcd.print(minute);
    lcd.print(":");
    if (sec<10) lcd.print("0");
    lcd.print(sec);
    lcd.print(":");
    lcd.print(ms);
  }
void resetNwelcome(){
  ms=0;minute=0;sec=0;
  lcd.setCursor(0,1);
  lcd.print("XW's Stopwatch");
  lcd.setCursor(0,0);
  lcd.print("Welcome to use");
}

void setup() {
lcd.begin(16,2);
pinMode(2,INPUT);
pinMode(3,INPUT);
}

void loop() {
  num_rise=0;
  resetNwelcome();
  ss1=digitalRead(2);
if (ss1 == HIGH) 
{
  num_rise++;
  last=millis();
  lcd.clear();
  while(1) //stop
  {
    switch(num_rise%2)
    {
      case 0:   //pause
      ss2=digitalRead(3);
      ss1=digitalRead(2);
      dur=millis()-last;
      if (ss2==HIGH) {reset=1;break;}
      else if(ss1==HIGH && dur>300) {
        num_rise++;
        last=millis();}
      break;
      case 1:   
      timeNprint();
      ss1=digitalRead(2);dur=millis()-last;
      if (ss1==HIGH &&dur>300) {
        num_rise++;
        last=millis();
        } 
      break;
      
     }
      ss2=digitalRead(3);
      dur2=millis()-last2;
    if(ss2==1 && dur2>300) 
    {
      last2=millis();
      printTime();
      }
    if(reset==1) 
    {reset=0;lcd.clear();row=0;break;}
   }
}
}

Schematics

qq20180528045242_GpOUugAqbp.jpg
Qq20180528045242 gpouugaqbp

Comments

Similar projects you might like

Arduino Nano LCD Stopwatch Without Potentiometer

Project tutorial by TechWithZan

  • 9,300 views
  • 9 comments
  • 17 respects

Simple Arduino Digital Clock Without RTC

Project in progress by Annlee Fores

  • 96,164 views
  • 23 comments
  • 80 respects

Minimal MIDI Drum Kit with 3D Printer

Project tutorial by ryokosaka

  • 10,284 views
  • 1 comment
  • 30 respects

Stopwatch and Lap Time Counter

Project showcase by LAGSILVA

  • 13,905 views
  • 5 comments
  • 24 respects

Arduino Kitchen Timer

Project tutorial by Team I and myself

  • 54,451 views
  • 37 comments
  • 77 respects

Arduino UNO Fan Controller Education Kit

Project showcase by ArdLab_Gent

  • 2,447 views
  • 0 comments
  • 11 respects
Add projectSign up / Login