Random for loop

From Interaction Station Wiki
Jump to navigation Jump to search


import time
import random
from adafruit_circuitplayground import cp
cp.pixels.brightness=0.3

while True:

    for x in range (0,12):
      
        for j in range (0,10,1):
            print(j)
            cp.pixels[j]=(255,j*20,0)
            time.sleep(0.2)
            cp.pixels[j]=(0,0,0)
        for j in range (9,-1,-1):
            print(j)
            cp.pixels[j]=(random.randint(0,255),random.randint(0,255),random.randint(0,255))
            time.sleep(0.5)
            #cp.pixels[j]=(0,0,0)
        time.sleep(0.5)