Permanent coloring for text in p5.js

Could anyone please suggest a way to not loop the text colour separately from my sound loop.

I was creating a timer which would highlight as red after the last 5 seconds. Also, I added a beep sound to remind the user(though it’s not perfect for publishing). If the number of seconds is more than 5, the text would be highlighted as green.but as a cold I noticed that the red colour is blinking each time a second passes. but I want it to be red permanently before the last 5 seconds. Could anyone suggest a way to fix this issue?My Countdown Timer Regards, Johann…

When yourtimeLeft <= 5 you can toggle a boolean. Check the state of that boolean and when true set the bg color to red.

     has5SecLeft = true;
if (has5secleft) {
  bg = color(255,0,0);
} else {
  bg = color(0,255,0);
1 Like