Stopwatch Using Arduino & LCD – Start Stop Reset Button
In this project, we have designed Simple Stopwatch Using Arduino & LCD Display with Start, Stop & Reset Button. A stopwatch will always have 2 buttons or modes, a start, and a stop mode. It may have other features but it will always have these. Additionally, we have added reset function too. This can be done with the pressing reset button of Arduino.
The millis feature of the Arduino Code allows the Arduino to display the functions up to the value in milliseconds to 100% accuracy. We can display up to 4 digits after the decimal point. But here we just displayed 2 digits. The same project can be done using a 4 digit 7 segment display.
You can go through the other version of this project: Stopwatch Using 4 Digit 7 Segment Display & Arduino
Components Required:
We just need a few of these components to assemble the circuit as given below.
1. Arduino UNO Board
2. 16*2 LCD Display
3. Push Buttons – 2
4. Breadboard
5. Connect jumpers wires
Circuit: Stopwatch Using Arduino & LCD Display
Assemble the circuit as shown in the figure below and make the following connections.
Connect Pin no 4,6,11,12,13,14 of LCD to Pin no 7,6,5,4,3,2 of Arduino.
Connect the two push buttons to digital pin 8 and 9 of Arduino.
Working & Operations:
Once the code is uploaded to Arduino Board, it will display press start. So just press the start button and then the time elapsing starts. To stop the time elapsed just press another button, i.e Stop button. Hence the stopwatch will stop. Now if you want to reset the circuit, then simply press the reset button of the Arduino UNO Board.
Source Code/Program:
Here is the code for Stopwatch Using Arduino & LCD Display. Copy it and upload it to your Arduino UNO Board.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
#include <LiquidCrystal.h> LiquidCrystal lcd(7, 6, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); lcd.clear(); Serial.begin(9600); pinMode(8, INPUT); digitalWrite(8, HIGH); pinMode(9, INPUT); digitalWrite(9, HIGH); } double i = 0; double a = millis(); double c ; void loop() { lcd.clear(); lcd.print("press start"); delay(100); if(digitalRead(8) == LOW) { lcd.clear(); a = millis(); while(digitalRead(9) == HIGH) { c = millis(); i = (c - a) / 1000; lcd.print(i); lcd.setCursor(7,0); lcd.print("Sec's"); lcd.setCursor(0,0); Serial.println(c); Serial.println(a); Serial.println(i); Serial.println("......"); delay(100); } if(digitalRead(9) == LOW) { while(digitalRead(8) == HIGH) { lcd.setCursor(0,0); lcd.print(i); lcd.setCursor(11,0); lcd.print(""); lcd.setCursor(0,0); delay(100); } } } } |
Video Demonstration:
Check other Arduino Projects
11 Comments
Hello!
Im trying to change this code to fit my project.
Wat im trying to create is a timecounter thet counts when a button i pushed in. And then stoped and resetted when button is relesed.
Is this possible in some easy way with thos code? 🙂
Tnx for help and sorry fore the bad english spelling.
I am wondering about using an Arduino to do something similar. What I want is efectively a staopwatch, started by one contact, stopped by another, mutually exclusive. It also needs to output the time in character form to a dot matrix printer, The same output will also be parsed into a spreadsheet on a laptop.
Does that sound possible? .
I made a Stopwatch with 2 buttons, I want that a button run the timer and pause if I press it again, and the other to reset the chronometer. I did the stopwach run but i can’t make it pause, rerun and reset, can you help me?
there is the code
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,4,5,6,7);
int botao1 = 8;
int botao2 = 9;
int estadoBotao1 = 0;
int estadoBotao2 = 0;
int sec, min, hora;
unsigned long zero;
void cronometro();
void pausa();
void setup(){
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print(“Cronometro do”);
delay(200);
lcd.setCursor(1,1);
lcd.print(“Ian Rapini ._.”);
delay(800);
lcd.clear();
pinMode(botao1, INPUT);
pinMode(botao2, INPUT);
sec = 0;
min = 0;
hora = 0;
zero = 0;
delay(300);
}
void loop(){
}
void cronometro(){
estadoBotao2 = digitalRead(botao2);
estadoBotao1 = digitalRead(botao1);
lcd.clear();
lcd.print(“Clique no Botao”);
delay(100);
if(estadoBotao2 == HIGH){
sec = 0;
min = 0;
hora = 0;
zero = 0;
lcd.clear();
{
sec++;
zero = millis();
}
if(sec > 59)
{
lcd.setCursor(10, 1);
lcd.print(” “);
sec = 0;
min++;
}
if(min > 59)
{
lcd.setCursor(5, 1);
lcd.print(” “);
min = 0;
hora++;
}
if(hora == 24){
hora = 0;
}
lcd.setCursor(2, 0);
lcd.print(hora);
lcd.setCursor(4, 0);
lcd.print(“h”);
delay(100);
lcd.setCursor(0, 1);
lcd.print(min);
lcd.setCursor(2, 1);
lcd.print(“m”);
delay(100);
lcd.setCursor(5, 1);
lcd.print(sec);
lcd.setCursor(7, 1);
lcd.print(“s”);
delay(100);
}
if(estadoBotao1 == HIGH){
while(estadoBotao2 == LOW){
sec = 0;
min = 0;
hora = 0;
zero = 0;
lcd.clear();
}
}
}
}
made a Stopwatch with 2 buttons, I want that a button run the timer and pause if I press it again, and the other to reset the chronometer. I did the stopwach run but i can’t make it pause, rerun and reset, can you help me?
there is the code
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,4,5,6,7);
int botao1 = 8;
int botao2 = 9;
int estadoBotao1 = 0;
int estadoBotao2 = 0;
int sec, min, hora;
unsigned long zero;
void cronometro();
void pausa();
void setup(){
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print(“Cronometro do”);
delay(200);
lcd.setCursor(1,1);
lcd.print(“Ian Rapini ._.”);
delay(800);
lcd.clear();
pinMode(botao1, INPUT);
pinMode(botao2, INPUT);
sec = 0;
min = 0;
hora = 0;
zero = 0;
delay(300);
}
void loop(){
}
void cronometro(){
estadoBotao2 = digitalRead(botao2);
estadoBotao1 = digitalRead(botao1);
lcd.clear();
lcd.print(“Clique no Botao”);
delay(100);
if(estadoBotao2 == HIGH){
sec = 0;
min = 0;
hora = 0;
zero = 0;
lcd.clear();
{
sec++;
zero = millis();
}
if(sec > 59)
{
lcd.setCursor(10, 1);
lcd.print(” “);
sec = 0;
min++;
}
if(min > 59)
{
lcd.setCursor(5, 1);
lcd.print(” “);
min = 0;
hora++;
}
if(hora == 24){
hora = 0;
}
lcd.setCursor(2, 0);
lcd.print(hora);
lcd.setCursor(4, 0);
lcd.print(“h”);
delay(100);
lcd.setCursor(0, 1);
lcd.print(min);
lcd.setCursor(2, 1);
lcd.print(“m”);
delay(100);
lcd.setCursor(5, 1);
lcd.print(sec);
lcd.setCursor(7, 1);
lcd.print(“s”);
delay(100);
}
if(estadoBotao1 == HIGH){
while(estadoBotao2 == LOW){
sec = 0;
min = 0;
hora = 0;
zero = 0;
lcd.clear();
}
}
}
}
Hi i have tm1637 ,can u help with code for?
No, sorry. I looked up what it is. I don’t have one. There appears to be plenty of stuff on line.
hey, I have made the same circuit but this code is not working. can you please guide me about it?
I have not worked on it for a bit. I’ll look if it is an old version. Are you using the same LCD shield? I found it quite difficult to get breadboard connections working reliably.
Is it doing anything? If backlight isn’t working, there is a connection issue.
I booted up a version I have. Not checked which code. It had progressed. The display was not updated, but it uses pin 3 to earth to start, pin 2 to stop. Done this way to use tape switches to operate. You should be able to see this in the code.
how to make the iteration of the stopwatch 0.5 s (500ms) ?