# Code for Task #1 - Random Random Roger Roger!

**URL:** <https://forum.electromage.com/t/code-for-task-1-random-random-roger-roger/952>\
**Category:** Pixelblaze Academy of Wizardry and Enchantment\
**Created:** [January 30, 2021, 11:47pm UTC](https://forum.electromage.com/t/code-for-task-1-random-random-roger-roger/952 "2021-01-30T23:47:12Z")\
**Posts on this page:** 1\
**Showing post:** 37

<div class="post-metadata">

**Author:** ![zranger1](https://forum.electromage.com/user_avatar/forum.electromage.com/zranger1/32/301_2.png) [@zranger1](https://forum.electromage.com/u/zranger1)\
**Post date:** [February 20, 2021, 2:44am UTC](https://forum.electromage.com/t/code-for-task-1-random-random-roger-roger/952/37 "2021-02-20T02:44:14Z")

</div>

In your beforeRender() function: @jeff’s suggestions are good ones.

Near the line `theLitPixel=floor(random(pixelCount))`, you have is the right idea. You’re selecting the pixel you want to light at frame time. Thing is, unless it’s controlled by your timer, ( `if (plusDelta > 3200)...`), it will select a new pixel on **every** frame.

This is what curly braces are all about - they’re just a general purpose mechanism for marking off functional blocks of code. So if you set that piece of code up like this:

```auto
  if (plusDelta > 3200) {
    plusDelta = 0 // Max total cycle is 3,200 Ms, randomized 
    theLitPixel=floor(random(pixelCount))
    hue = random(1)
    sat = random(1)
    v = random(1)
    v=pow(v,2.5)
 }

```

all the code between `{` and `}` will only be executed every 3.2 seconds, which will give you the timing control you’re looking for.

---

_[View the full topic](https://forum.electromage.com/t/code-for-task-1-random-random-roger-roger/952)._
