# Help Any one give me info where i find one digital timer for Android mode

**URL:** <https://discourse.processing.org/t/help-any-one-give-me-info-where-i-find-one-digital-timer-for-android-mode/29293>\
**Category:** Processing for Android\
**Tags:** homework\
**Created:** [April 12, 2021, 7:11am UTC](https://discourse.processing.org/t/help-any-one-give-me-info-where-i-find-one-digital-timer-for-android-mode/29293 "2021-04-12T07:11:27Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [April 12, 2021, 9:00am UTC](https://discourse.processing.org/t/help-any-one-give-me-info-where-i-find-one-digital-timer-for-android-mode/29293/4 "2021-04-12T09:00:48Z")

</div>

> [@A timer which activates by pressing a button](https://discourse.processing.org/t/a-timer-which-activates-by-pressing-a-button/25818):
>
> I’m trying to make a timer which starts by pressing a button. I’ve tried millis() but it starts counting as soon as I start the program.

:

```auto
// The duration of the timer
int timerDuration = 2000;

// The time at which we start the timer
int startTime = 0;

// Whether or not the timer was started
boolean timerStarted = false;

void setup() {
  size(200, 200);
}

void draw() {
  background(255);
  
  if (timerStarted) {
    // We subtract the current time and the time when we started the timer
    int currentDuration = millis() - startTime;
    
    fill(0);
    textAlign(CENTER, CENTER);
    text(currentDuration, width / 2, height / 2);
    
    // If the event is over
    if (currentDuration > timerDuration) {
      timerStarted = false;
    }
  }
}

// When the mouse is pressed, take the current time and store it
void mousePressed() {
  startTime = millis();
  timerStarted = true;
}

```

---

_[View the full topic](https://discourse.processing.org/t/help-any-one-give-me-info-where-i-find-one-digital-timer-for-android-mode/29293)._
