Python bluefruit string manipulation , and creating a lightshow with the given rgb values

21 views Asked by At

Im currently coding on a bluefruit with circuit playground on Python. The assignment is as follows

from adafruit_circuitplayground import cp
import time


def light_show(encoding):
    print("light_show() has been called .. making awesome light show .. now!")
    # Your Work Here


encoding = "B4R2G0R3B9G7R1G4B8R6G5R4G2B0G3R9B7G1B4R8G6B5B4R2G0R3B9G7R1G4B8R6G5R4G2B0G3R9B7G1B4R8G6B5"
baseline = cp.temperature

# You might need to experiment with the following value.
# It might be too sensitive, or not sensitive enough.
temp_delta = 0.2
 
while cp.temperature < baseline + temp_delta:
    pass
light_show(encoding)

It is essentially a problem on string manipulation of separating the RGB values given in the encoding string, but I'm lost on how to make that in a for loop.

The code related to temperature is essentially done for us, as the lightshow function goes off when it is warmed up enough.

0

There are 0 answers