Display images alternately

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

PImage img1;
PImage img2;

void setup () {

  img1 = loadImage("step5.png");
  img2 = loadImage("fail2.png");


void draw (){

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.

If I use:


there is the same issue.

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.

basically best is NOT to use


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 ) this