What is a Digital Stopwatch?
A digital stopwatch can be a circuit displaying the actual time in minutes, hours and seconds or a circuit displaying the number of clock pulses.
A stopwatch is used to measure the time interval of an event. It is a kind of watch that stands out for the accuracy and precision with which it can measure the time of an event. It works by pressing a start button and then stopping it. It is also known as a chronometer and is used to measure fractions of time, usually short and accurately. Basically there are two types of stopwatch, Digital stopwatch, and Analog stopwatch.
How a stopwatch works
The operation of a stopwatch is to accurately count the time of an event. The timers are easy to use, to start the count you must press a start button. Once the event is over, time stops on the stop button.
The time covered by the recorded event will be displayed on the face of the wristwatch, as well as other common data, such as time and date. You can restart the stopwatch to count another event or event. There are wristwatches that have a chronometer, but there are also models that can be hung on the neck or carried in the pocket.
You all have a Stopwatch at your home.
Have you ever wondered to make a Stopwatch at home using some Electronics components?
If yes, You are in the right blog page.
In this Blog I'll tell you How you can make a Digital Stopwatch using Arduino at home..
Just read the whole blog.
Just Copy the Arduino code and paste it in Arduino IDE.
#include <LiquidCrystal.h> //LibrariesLiquidCrystal lcd(2, 3, 4, 5, 6, 7); //Arduino pins to lcd#define bt_start A0#define bt_stop A1#define bt_reset A2#define G_led 8#define R_led 9#define buzzer 13int hh=0, mm=0, ss=0, ms=0;bool timerStart = false;void setup() { // put your setup code here, to run oncepinMode(bt_start, INPUT_PULLUP);pinMode(bt_stop, INPUT_PULLUP);pinMode(bt_reset, INPUT_PULLUP);pinMode(R_led,OUTPUT); // declare Red LED as outputpinMode(G_led,OUTPUT); // declare Green LED as outputpinMode(buzzer,OUTPUT); // declare Buzzer as outputlcd.begin(16, 2); // Configura lcd numero columnas y filaslcd.clear();lcd.setCursor (0,0);lcd.print(" Welcome To ");lcd.setCursor (0,1);lcd.print(" Stopwatch ");delay(2000);lcd.clear();noInterrupts(); // disable all interruptsTCCR1A = 0; // set entire TCCR1A register to 0 //set timer1 interrupt at 1kHz // 1 msTCCR1B = 0; // same for TCCR1BTCNT1 = 0; // set timer count for 1khz incrementsOCR1A = 1999; // = (16*10^6) / (1000*8) - 1//had to use 16 bit timer1 for this bc 1999>255, but could switch to timers 0 or 2 with larger prescaler// turn on CTC modeTCCR1B |= (1 << WGM12); // Set CS11 bit for 8 prescalerTCCR1B |= (1 << CS11); // enable timer compare interruptTIMSK1 |= (1 << OCIE1A);interrupts(); // enable}void loop() {if(digitalRead (bt_start) == 0){digitalWrite(buzzer, HIGH);timerStart = true; // Start stopwatchdelay(100);}if(digitalRead (bt_stop) == 0){digitalWrite(buzzer, HIGH);timerStart = false; // Stop stopwatchdelay(100);}if(digitalRead (bt_reset) == 0){digitalWrite(buzzer, HIGH);ms=0, ss=0, mm=0, hh=0; // Reset stopwatchdelay(100);}lcd.setCursor (0,0);lcd.print(" Stopwatch ");lcd.setCursor (2,1);lcd.print((hh/10)%10);lcd.print(hh%10);lcd.print(":");lcd.print((mm/10)%10);lcd.print(mm%10);lcd.print(":");lcd.print((ss/10)%10);lcd.print(ss%10);lcd.print(":");lcd.print((ms/100)%10);lcd.print((ms/10)%10);lcd.print(ms%10);if(timerStart==true){digitalWrite(G_led, HIGH); // Turn LED on.digitalWrite(R_led, LOW); // Turn LED off.}else{digitalWrite(G_led, LOW); // Turn LED off.digitalWrite(R_led, HIGH); // Turn LED on.}digitalWrite(buzzer, LOW);}ISR(TIMER1_COMPA_vect){if(timerStart == true){ms=ms+1;if(ms>999){ms=0;ss=ss+1;if(ss>59){ss=0; mm=mm+1;}if(mm>59){mm=0; hh=hh+1;}}}}
0 Comments