Introduction: Arduino Stopwatch

This Instructable will show you how to make a stop watch out of an Arduino.

Step 1: What You Will Need

Please buy through these Amazon links as it helps me to keep making these Instructables (A small cut of Amazon's profit from the sale is given to me - It doesn't cost you anything!)

You Will Need:

- 1x Arduino Uno:

-US Link: http://amzn.to/2mikwN9

-UK Link: http://amzn.to/2e9HwgA


- 1x LCD Keypad Shield:

-US Link: http://amzn.to/2neqIEW

-UK Link: http://amzn.to/2fnLHTx


- 1x USB A - B Connector Cable:

-US Link: http://amzn.to/2ne6xqW

-UK Link: http://amzn.to/2e9NL3L

What I Recommend:

- Amazon Prime so you can get all your items the next day:

-US Link: https://www.amazon.com/tryprimefree?ref_=assoc_tag...

-UK Link: http://www.amazon.co.uk/tryprimefree?tag=instructabl00-21

- You could attach some of these magnets to attach the stopwatch onto nearly anything metal:

-US Link: http://amzn.to/2miAqqS

-UK Linkhttps://goo.gl/m4Bg1N


- Arduino For Dummies (very helpful when learning code):

-US Link: http://amzn.to/2mAWM99

-UK Link: https://www.amazon.co.uk/gp/product/1118446372/ref...

or

- Arduino Projects For Dummies:

-US Link: http://amzn.to/2mipWrj

-UK Link: http://amzn.to/2fMuCoS

Step 2: Slot the LCD Display Onto the Arduino

This step is very simple just slot the LCD display onto the Arduino.

Step 3: Connect and Install the Program

Just connect your Arduino to The Computer and install the program.

Update - Please use the Modified Stopwatch Program.

Step 4: Run Your Stopwatch

Now just run your stopwatch.

Comments

author
AslamM3 made it! (author)2017-05-20

thank you very much

WhatsApp Image 2017-05-20 at 11.10.05 PM.jpeg
author
scratchndent made it! (author)2017-02-12

i made it but i am sorry to say that it did not work for both versions

IMG_0008 2.JPG
author
Elac. made it! (author)2015-05-12

Very cool idea and a great starting point, thanks!!!

I did a bit of rewrite to make it more accurate and display the time as it progresses plus other tweaks :

/*

Standalone Arduino StopWatch

By Conor M - 11/05/15

Modified by Elac - 12/05/15

*/

// call the necessary libraries
#include <SPI.h>
#include <LiquidCrystal.h>
// these are the pins used on the shield for this sketch
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
// variables used on more than 1 function need to be declared here
unsigned long start, finished, elapsed;
boolean r = false;
// Variables for button debounce time
long lastButtonPressTime = 0; // the last time the button was pressed
long debounceDelay = 50; // the debounce time; keep this as low as possible

void setup()
{
lcd.begin(16, 2); // inicialize the lcd (16 chars, 2 lines)

// a little introduction :)
lcd.setCursor(4, 0); // set the cursor to first character on line 1 - NOT needed (it sets automatically on lcd.begin()
lcd.print("Arduino");
lcd.setCursor(3, 1); // set the cursor to 4th character on line 2
lcd.print("StopWatch");
delay(2000); // wait 2 seconds
lcd.clear(); // clear the display
lcd.print("Press select for");
lcd.setCursor(2, 1); // set the cursor to 3rd character on line 2
lcd.print("Start & Stop");
}

void loop()
{
CheckStartStop();
DisplayResult();
}

void CheckStartStop()
{
int x = analogRead (0); // assign 'x' to the Arduino's AnalogueInputs (Shield's buttons)
if (x < 800 && x > 600 ) // if the button is SELECT
{
if ((millis() - lastButtonPressTime) > debounceDelay)
{

if (r == false)
{
lcd.clear();
lcd.setCursor(2, 0); // needed
lcd.print("Elapsed Time");
start = millis(); // saves start time to calculate the elapsed time
}
else if (r == true)
{
lcd.setCursor(2, 0); // needed
lcd.print(" Final Time ");
}
r = !r;
}
lastButtonPressTime = millis();
}
}

void DisplayResult()
{
if (r == true)
{
finished = millis(); // saves stop time to calculate the elapsed time
// declare variables
float h, m, s, ms;
unsigned long over;

// MATH time!!!
elapsed = finished - start;

h = int(elapsed / 3600000);
over = elapsed % 3600000;
m = int(over / 60000);
over = over % 60000;
s = int(over / 1000);
ms = over % 1000;
// display the results
lcd.setCursor(0, 1);
lcd.print(h, 0); // display variable 'h' - the 0 after it is the number of algorithms after a comma (ex: lcd.print(h, 2); would print 0,00
lcd.print("h "); // and the letter 'h' after it
lcd.print(m, 0);
lcd.print("m ");
lcd.print(s, 0);
lcd.print("s ");
if (h < 10)
{
lcd.print(ms, 0);
lcd.print("ms ");
}
}
}

author
wobblybob808 made it! (author)wobblybob8082016-12-26

Elac,

I only want to count time while the button or another input is present , how would I go about this?

author
heavypetal made it! (author)2016-12-13

I'm struggling to get external buttons to work - I want to add a start and stop but keep getting stuck! Anybody done this with the modified code? :)

author
bennyleo made it! (author)2016-11-28

Welcome to join the group :)

https://www.facebook.com/groups/305526369783769/

author
jagdeep010 made it! (author)2016-09-01

how to install the program I don't see anything on my computer after connecting the arduino to it. do we need some software like matlab or something?

author
Conor M made it! (author)Conor M2016-09-01

Make sure you have downloaded the arduino software from https://www.arduino.cc/en/Main/Software

author
amans149 made it! (author)2016-08-24

I want a coding I want to connect ir sensor to micro servo so that if something pass from front of ir sensor servo rotates at a 90 degree angle and returns to its initial position. I have a ARDUINO UNO for the purpose.... Can anybody do coding for this..PLZ PLZ PLZ THANK YOU... HOPE U REPLY...

please reply here --http://arduino.stackexchange.com/questions/28666/coding-for-connect-servo-with-ir-sensor-to-ardiuino

author
Conor M made it! (author)Conor M2016-08-24

The code is there for you to use

author
Conor M made it! (author)Conor M2016-08-24

Check out one of my other instructables, how to make an arduino web server, it uses a servo, hope it helps

author
محمودع10 made it! (author)2016-08-03

nice

author
R Jordan Kreindler made it! (author)2016-07-11

Outstanding. I am using it and am happy to say it works without problem.

author
musi mumu made it! (author)2016-03-05

can somebody give me a version for measuring and displaying seconds,miliseconds and microseconds all on 3 digits each . If yes thanks in advance and contact me at mmedocean@gmail.com

author
vianch_tog made it! (author)2016-02-10

works

author
Avangura made it! (author)2015-12-14

on the line elapsed = finished - start I am getting an error 'start' was not declared in this scope.

Any ideas?

author
Conor M made it! (author)Conor M2016-02-09

is your software up to date?

author
HectorR28 made it! (author)2016-01-04

can i have the schematic diagram...

author
Conor M made it! (author)Conor M2016-02-09

sorry I don't have a schematic

author
Avangura made it! (author)2015-12-18

OK - got it working and it is great! Can you instruct me on how I can replace the SELECT button with an external switch for an experiment I am working on?

author
Riscyg made it! (author)2015-12-16

Very nice, works as it says. Thanks :)

Arduino_i made it.jpeg
author
spacetoon34 made it! (author)2015-09-09

Brilliant

I have tried to gather all my collection of websites and youtube channels and videos in one place. There are many things also to introduce to you in an elegant way so I established this site : www.speakelectronics.com and I hope you like it.

Regards,
-----------------------
www.speakelectronics.com

author
Ofibro made it! (author)Ofibro2015-12-02

Wish I could see it!

it says data base error and then a blank page with only

"Error establishing a database connection"
author
Riscyg made it! (author)2015-11-26

Very simple - I will give this s go this weekend, thanks :)

author
ankur sharma made it! (author)2015-11-21

sir , which pin of display is connected to which pin of arduino

author
Conor M made it! (author)Conor M2015-11-21

I don't know but I got the module from banggood.com

author
ankur sharma made it! (author)2015-11-21

sir , which pin of display is connected to which pin of arduino

author
XanderS1 made it! (author)2015-10-05

awesome project

author
Machine made it! (author)2015-05-24

Very tidy Arduino project.

author
Conor M made it! (author)2015-05-12

I have modified Elac's modified program please update your program to this one if you are using it.

Thanks

author
Conor M made it! (author)2015-05-12

just uploaded it it is very good

Thx

author
Conor M made it! (author)2015-05-12

I will upload this to my arduino

Thx

author
honey181 made it! (author)2015-05-12

Quite nice and easy! :)

author
Conor M made it! (author)Conor M2015-05-12

Thanks

author
Conor M made it! (author)2015-05-11

Thanks

About This Instructable

50,326views

218favorites

License:

Bio: If it moves and it isn't supposed to move, Duct Tape it. If it doesn't move and its supposed to move, WD40 it ... More »
More by Conor M:Arduino Web ServerPhosphorous PowderArduino Stopwatch
Add instructable to: