Some problems about millis()

Why I can’t make a 30-second timer with the below codes?

int time;
int startTime;

void setup()
{
  background(0);
  size(800, 1000);
  time = millis();
  startTime = 30;
  
}

void draw()
{
  fill(250, 255, 8);
  textSize(30);
  text("Time: "+ (startTime - time/1000) + "s", 20, 100);
}

Instead of time use milis() in this line

In setup this should be startTime=millis()

A timer would be millis() - startTime > 3000

1 Like