# Millis() doubt: how to do the program wait two seconds before doing anything?

**URL:** <https://discourse.processing.org/t/millis-doubt-how-to-do-the-program-wait-two-seconds-before-doing-anything/1579>\
**Category:** Coding Questions\
**Created:** [July 7, 2018, 4:33pm UTC](https://discourse.processing.org/t/millis-doubt-how-to-do-the-program-wait-two-seconds-before-doing-anything/1579 "2018-07-07T16:33:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![parzival](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@parzival](https://discourse.processing.org/u/parzival)\
**Post date:** [July 7, 2018, 4:33pm UTC](https://discourse.processing.org/t/millis-doubt-how-to-do-the-program-wait-two-seconds-before-doing-anything/1579/1 "2018-07-07T16:33:56Z")

</div>

Hello. I’m new here and I’m trying to make the program wait two seconds before doing anything, but I do not know exactly how to do it. For example, how can I draw a rectangle, then wait two seconds and draw another one, then draw another one two seconds later?

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [July 7, 2018, 4:38pm UTC](https://discourse.processing.org/t/millis-doubt-how-to-do-the-program-wait-two-seconds-before-doing-anything/1579/2 "2018-07-07T16:38:47Z")

</div>

You’re on the right track: you can use the `millis()` function or the `frameCount` variable to check how much time has elapsed.

Here’s an example that displays a circle for 60 frames whenever you click the mouse:

```auto
int clickedFrame = -999;

void draw(){

  background(0);

  if(frameCount < clickedFrame + 60){
    ellipse(width/2, height/2, width, height);
  }
}

void mousePressed(){
  clickedFrame = frameCount;
}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 7, 2018, 4:50pm UTC](https://discourse.processing.org/t/millis-doubt-how-to-do-the-program-wait-two-seconds-before-doing-anything/1579/3 "2018-07-07T16:50:35Z")

</div>

You may try out my “Countdown.java” file: 😺

- [https://Forum.Processing.org/two/discussion/27733/countdown-class-library-for-java-js-python](https://Forum.Processing.org/two/discussion/27733/countdown-class-library-for-java-js-python)

> **[Countdown Class](http://Bl.ocks.org/GoSubRoutine/1a0d21828319cf18fecf44101764bd60)**
>
> GoSubRoutine’s Block 1a0d21828319cf18fecf44101764bd60
