April 2018
Beginner
552 pages
13h 58m
English
We can add new functions to our library to produce different effects, such as generating random colors. The following function uses randint() to get a value between 1 and the number of colors. We ignore any values that are over the number of the available colors so that we can control how often the LEDs are switched off. Perform the following steps to add the required functions:
from random import randint
def led_rgbrandom(led,period,colors): ''' Light up the selected led, for period in seconds, in one of the possible colors. The colors can be 1 to 3 for RGB, or ...