# Color randomizing time reaction game

**URL:** <https://discourse.processing.org/t/color-randomizing-time-reaction-game/20222>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [April 28, 2020, 5:55am UTC](https://discourse.processing.org/t/color-randomizing-time-reaction-game/20222 "2020-04-28T05:55:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 30, 2020, 12:08pm UTC](https://discourse.processing.org/t/color-randomizing-time-reaction-game/20222/2 "2020-04-30T12:08:51Z")

</div>

> [@stanley](#):
>
> How do I cycle through the 6 colors?

```auto
// -------------------------------------------------------------------------------
// color constants

final color WHITE = color(255);
final color BLACK = color(0);

final color DARKGRAY = color(110); 
final color LIGHTGRAY = color(200); 

final color RED = color(255, 0, 0);
final color GREEN = color(0, 255, 0);
final color BLUE = #0326FF; 

final color YELLOW = #FFF703; 
final color BROWN = (#B9780D); 

final color[] colList = 
  {
  RED, WHITE, BLUE, RED, YELLOW, GREEN, LIGHTGRAY, BROWN
};

// variables 
int i; 

// -------------------------------------------------------------------------------

void setup() {
  size(600, 600);
  background(200);
}

void draw() {
  background(200);
  fill(colList[i%colList.length]);
  rect(100, 100, 
    200, 200);
}

// -------------------------------------------------------------------------------

void keyPressed() {
  i++;
}
//

```

* * *

> [@stanley](#):
>
> How do I implement a Timer to help accomplish this?

> [@Reaction time experiment](https://discourse.processing.org/t/help-with-reaction-time-experiment/19813/5):
>
> thank you! I realized that. Now I’m having a problem with having the calculation of the reaction time work. It should show the time that it takes for the user to press space since the square turned red. Could you help? boolean startTimer = false; int startingTimer; int CONSTANT = 1000; int r; int timeOne; int timeTwo; int totalTime; int reactionTime; boolean reaction; void setup() { // setting up the initial screen size(800, 800); textSize(36); text("Reaction time experiment", 180, 200…

Chrisir

---

_[View the full topic](https://discourse.processing.org/t/color-randomizing-time-reaction-game/20222)._
