# I want to create a pattern where i have 4 different squares in different colours that directly change color as a code. This is what i have, but i dont know how to change the color of the sqaures and then turn them back to normal in one time. Please help

**URL:** <https://discourse.processing.org/t/i-want-to-create-a-pattern-where-i-have-4-different-squares-in-different-colours-that-directly-change-color-as-a-code-this-is-what-i-have-but-i-dont-know-how-to-change-the-color-of-the-sqaures-and-then-turn-them-back-to-normal-in-one-time-please-help/33254>\
**Category:** Coding Questions\
**Created:** [November 2, 2021, 10:18am UTC](https://discourse.processing.org/t/i-want-to-create-a-pattern-where-i-have-4-different-squares-in-different-colours-that-directly-change-color-as-a-code-this-is-what-i-have-but-i-dont-know-how-to-change-the-color-of-the-sqaures-and-then-turn-them-back-to-normal-in-one-time-please-help/33254 "2021-11-02T10:18:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeRonald](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LeRonald](https://discourse.processing.org/u/LeRonald)\
**Post date:** [November 2, 2021, 10:18am UTC](https://discourse.processing.org/t/i-want-to-create-a-pattern-where-i-have-4-different-squares-in-different-colours-that-directly-change-color-as-a-code-this-is-what-i-have-but-i-dont-know-how-to-change-the-color-of-the-sqaures-and-then-turn-them-back-to-normal-in-one-time-please-help/33254/1 "2021-11-02T10:18:40Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

int lastTimeCheck;  
int timeIntervalFlag = 3000; // 3 seconds because we are working with millis

void setup() {  
size(500,500);  
background(0);  
fill(255,0,0);  
square(0,0,250);  
fill(0,255,0);  
square(250,0,250);  
fill(0,0,255);  
square(0,250,250);  
fill(255,255,0);  
square(250,250,250);  
lastTimeCheck = millis();  
}

void draw() {  
if ( millis() \> lastTimeCheck + timeIntervalFlag ) {  
lastTimeCheck = millis();  
println( “something awesome happens here” );  
}  
}

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [November 2, 2021, 12:25pm UTC](https://discourse.processing.org/t/i-want-to-create-a-pattern-where-i-have-4-different-squares-in-different-colours-that-directly-change-color-as-a-code-this-is-what-i-have-but-i-dont-know-how-to-change-the-color-of-the-sqaures-and-then-turn-them-back-to-normal-in-one-time-please-help/33254/3 "2021-11-02T12:25:27Z")

</div>

Hello @LeRonald,

Your code and timer work but need some tweaks!

`setup()` only runs once:  
[https://processing.org/reference/setup\_.html](https://processing.org/reference/setup_.html)

You can lookup the reference for `draw()`

Consider:

- moving your pattern of squares to `draw()`
- use color variables to assign color to each square
- change the color variable along with your timer

There are lots of resources here to help you on your journey:  
[https://processing.org/](https://processing.org/)

Nice pattern of squares!

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/07a3fca82665feb8478b69071406cbbc8d4124ae.png)

Reference:  
[https://processing.org/reference/square\_.html](https://processing.org/reference/square_.html)

`:)`
