# Display images alternately

**URL:** https://discourse.processing.org/t/display-images-alternately/13567
**Category:** Beginners
**Created:** [August 24, 2019, 10:27am UTC](https://discourse.processing.org/t/display-images-alternately/13567 "2019-08-24T10:27:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Moene](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@Moene](https://discourse.processing.org/u/Moene)
#### Post date: [August 24, 2019, 10:27am UTC](https://discourse.processing.org/t/display-images-alternately/13567/1 "2019-08-24T10:27:28Z")

</div>

How can I display an image in draw() successively with a delay between them?

```auto
PImage img1;
PImage img2;

void setup () {

  img1 = loadImage("step5.png");
  img2 = loadImage("fail2.png");
  size(801,583);  
  background(#B70F0F);  
  delay(2000);

}

void draw (){
  background(img1);
  delay(2000);
  background(img2);
  delay(2000);
}

```

When i run this it shows the background colour from setup() after 2 seconds, then it runs for 4 seconds and shows the secend image (img2). How can I just show an image and then another one? I need something similar for a project, where I want to show certain images when certain inputs come from a serial port. That works with console messages (println()), but if I let the program show images instead it runs to the end and only shows the last image.

---

<div class="post-metadata">

### Author: ![Moene](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@Moene](https://discourse.processing.org/u/Moene)
#### Post date: [August 24, 2019, 10:29am UTC](https://discourse.processing.org/t/display-images-alternately/13567/2 "2019-08-24T10:29:21Z")

</div>

If I use:

image(img1,0,0);

there is the same issue.

---

<div class="post-metadata">

### Author: ![Moene](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@Moene](https://discourse.processing.org/u/Moene)
#### Post date: [August 24, 2019, 10:33am UTC](https://discourse.processing.org/t/display-images-alternately/13567/3 "2019-08-24T10:33:54Z")

</div>

When I use rectangles instead of images there is also the same issue, so it has to be something wrong with my understanding of processing.

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [August 24, 2019, 11:11am UTC](https://discourse.processing.org/t/display-images-alternately/13567/4 "2019-08-24T11:11:16Z")

</div>

basically best is NOT to use

```auto
delay();

```

at all.

* * *

first for the understanding,  
draw() should run 60 times per second  
( show all what you want show at that moment / draw inside the whole draw() loop  
and yes, does not matter if image / shape / primitive … )

* * *

if you want show different things / at a different time /  
need a stage / timer concept /

* * *

a start timer code play with  
[Making a for loop ( or timer )](https://discourse.processing.org/t/making-a-for-loop-or-timer/6483/2) this
