Introduction: Easy Arduino Stopwatch

Hello. I will explain how did i make this simple stopwatch.

Step 1: Connections

Picture of Connections

Only connection is between arduino and 16x2 LCD screen.

Same as Arduino.cc tutorials

"LCD RS pin to digital pin 12

LCD Enable pin to digital pin 11

LCD D4 pin to digital pin 5

LCD D5 pin to digital pin 4

LCD D6 pin to digital pin 3

LCD D7 pin to digital pin 2

Additionally, wire a 10k pot to +5V and GND, with it's wiper (output) to LCD screens VO pin (pin3). A 220 ohm resistor is used to power the backlight of the display, usually on pin 15 and 16 of the LCD connector"

Step 2: Includes

We should include and declare LCD to use it. With adding those lines to beginning of sketch

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Then declare Second , Minute and Hour

int sec=0;
int min=0;

int hr=0;

You can change those if you want start Stopwatch from another hr/min/sec

Ex : int sec=50 will start stopwatch from 50. second

Step 3: Setup

We will start the 16x2 in void setup()

void setup() {
lcd.begin(16,2);

}

Hint : We can add countdown before stopwatch starts with adding these lines to void setup

lcd.print("CHRONOMETER");
delay(1000);

lcd.setCursor(0,0);

lcd.print("STARTS IN 5");

delay(1000);

lcd.clear();

lcd.print("STARTS IN 4");

delay(1000);

lcd.clear();

lcd.print("STARTS IN 3");

delay(1000);

lcd.clear();

lcd.print("STARTS IN 2");

delay(1000);

lcd.clear();

lcd.print("STARTS IN 1");

delay(1000);

lcd.clear();

lcd.setCursor(0,0);

Step 4: Loop !

This part counts second

main key is

sec=sec+1;

this line adds 1 to second on every loop

we will add

sec=sec+1;
delay(1000);

to mainloop for counting second

Step 5: Oh Wait ! Forgot Minutes and Hours

We will add those lines for convert second to hours and minutes

if(sec == 60){ //This "if" will add 1Minute to min and reset second
sec=00;

min=min+1;

}else;

if(min == 60){ //This "if" will add 1Hour to hr and reset minute

min=0;

hr=hr+1; }

else;

Step 6: Print to LCD !

We will add those lines to beginning of loop for print values to lcd

lcd.setCursor(2,2);
lcd.print("CHRONOMETER");

lcd.setCursor(4,0);

lcd.print(hr);

lcd.setCursor(6,0);

lcd.print(":");

lcd.print(min);

lcd.setCursor(9,0);

lcd.print(":");

lcd.print(sec);

and add

lcd.clear();

to end of loop for clear lcd on every loop

Step 7: Full Code

/*Arduino Chronometer V1.0*/
#include LiquidCrystal lcd(12, 11, 5, 4, 3, 2); int sec=00; int min=00; int hr=00;

void setup() { lcd.begin(16,2); lcd.setCursor(2,1); lcd.print("CHRONOMETER"); delay(1000); lcd.setCursor(0,0); lcd.print("STARTS IN 5"); delay(1000); lcd.clear(); lcd.print("STARTS IN 4"); delay(1000); lcd.clear(); lcd.print("STARTS IN 3"); delay(1000); lcd.clear(); lcd.print("STARTS IN 2"); delay(1000); lcd.clear(); lcd.print("STARTS IN 1"); delay(1000); lcd.clear(); lcd.setCursor(0,0); }

void loop() {

lcd.setCursor(2,2); lcd.print("CHRONOMETER"); lcd.setCursor(4,0); lcd.print(hr); lcd.setCursor(6,0); lcd.print(":"); lcd.print(min); lcd.setCursor(9,0); lcd.print(":"); lcd.print(sec); sec=sec+1; delay(1000);

if(sec == 60){ sec=00; min=min+1; }else; if(min == 60){ min=0; hr=hr+1; }else;

lcd.clear(); }

Comments

sandeepv21 (author)2016-11-12

Ok but how to stop the timer....

About This Instructable

4,246views

19favorites

License:

More by ugur23:Easy Arduino StopwatchDIY Usb Custom Flash Drive
Add instructable to: