How to do it...

To do this, perform the following steps:

  1. Run the following lines of code in the REPL:
>>> from adafruit_circuitplayground.express import cpx
>>> from random import randint
>>> randint(0, 255)
186
>>> randint(0, 255)
84
  1. Each time you run the previous lines of code, you should get a random integer between the values of 0 and 255.
  1. Use the following code to define a function, and then call the function to confirm that it is working correctly:
>>> def get_random_color():
...     return (randint(0, 255), randint(0, 255), randint(0, 255))
...     
...     
... 
>>> get_random_color()
(208, 161, 71)
>>> get_random_color()
(96, 126, 158)
  1. Call the following code repeatedly; the first NeoPixel should change to a random color on each call:
>>> cpx.pixels[0] = get_random_color()
  1. Set all the pixels to the same random color on each call using the following code:
>>> cpx.pixels.fill(get_random_color())