Close
0%
0%

Arduino Stopwatch

This project is about building your own stopwatch using the Arduino board and a few other components.

Similar projects worth following
The project describes how to build a stopwatch using Arduino and a few other components. That will help to set time without making any change in the code.

About Project

With the help of Arduino Stopwatch You can set the time without making any change in the code and it actually let you know when it reaches zero.

Connections

Connection is in between Arduino and 16x2 LCD screen.

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

In addition to that wire a 10k pot to +5V and GND, with it's 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.

After making connections and uploading program into the board. Set the time between range of 1 and 120 minutes. After identifying the time, it waits for 5 seconds and starts counting down. When the time is up, it beeps few times.

  • 1 × Arduino Uno
  • 1 × LCD with I2C Converter Capacitors / Ceramic
  • 1 × Rotary potentiometer (generic)
  • 1 × Jumper wires (generic)
  • 1 × Breadboard (generic)

  • 1
    Run a Program

    #include
    #include

    LiquidCrystal_I2C lcd(0x27,20,4);
    //this values will help us to choose the time
    long last_change;
    long last_value;
    long timer_value;
    void setup()
    {
    //inti lcd
    lcd.init();
    //turn on backlight
    lcd.backlight();
    pinMode(A0, INPUT);
    pinMode(8, OUTPUT);
    }

    void loop()
    {
    //if the value was changed less than 5 seconds ago this loop will work
    while(millis() - last_change < 5000){
    timer_value = map(analogRead(A0), 0, 1023, 1, 120);
    if(timer_value != last_value){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Timer");
    lcd.setCursor(0,1);
    lcd.print(timer_value);
    last_value = timer_value;
    last_change = millis();
    }
    delay(10);
    }
    //after 5 seconds this will happen
    lcd.clear();
    lcd.print("starting...");
    delay(3000);
    long target = last_change + (timer_value * 60 * 1000);
    //and then it will start displaying how much time there is until end of counting
    while(millis() < target){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Time left:");
    lcd.setCursor(0, 1);
    lcd.print((target - millis()) / 1000 / 60);
    delay(50);
    }
    //and few beeps at the end
    for(int a = 0; a < 10; a++){
    digitalWrite(8, HIGH);
    delay(500);
    digitalWrite(8, LOW);
    delay(500);
    }
    while(1);
    }

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates