# Timer without delay()

**URL:** https://discourse.processing.org/t/timer-without-delay/31080
**Category:** Coding Questions
**Created:** [July 5, 2021, 11:19pm UTC](https://discourse.processing.org/t/timer-without-delay/31080 "2021-07-05T23:19:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![millionish](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@millionish](https://discourse.processing.org/u/millionish)
#### Post date: [July 5, 2021, 11:19pm UTC](https://discourse.processing.org/t/timer-without-delay/31080/1 "2021-07-05T23:19:20Z")

</div>

I have written a code for a stopwatch (when button pressed, it starts), but I have used delay(). Is there a way to perform it without delay()?

```auto
lcd.setCursor(0, 1);
  if (buttonValue1 == LOW) {
    startTime = millis();
    timerMode++;
    delay(400);
  }
  if (timerMode == 1) {
    lcd.setCursor(0, 1);
    lcd.print("Time : ");
    lcd.setCursor(7, 1);
    lcd.print((millis() - startTime) / 1000.0);
    lcd.setCursor(12, 1);
    lcd.print(" sec");
  }
  if (timerMode > 1) {
    delay(6000);
    timerMode = 0;
    lcd.clear();
    lcd.setCursor(3, 0);
    lcd.print("TIMER");

```

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [July 6, 2021, 3:11am UTC](https://discourse.processing.org/t/timer-without-delay/31080/2 "2021-07-06T03:11:45Z")

</div>

> [@millionish](#):
>
> stopwatch

# [Adding a stopwatch to a clock](https://discourse.processing.org/t/adding-a-stopwatch-to-a-clock/5973)
