One of the ways you can see return values with your CoDrone Mini is through its LED and number randomization. Quick review from the LED lesson: an LED produces color as a combination of red, green, and blue. All of these values range from 0 to 255 corresponding to the color’s intensity, with 255 being the highest.
For this program, import the CoDrone Mini, time, and random libraries, and then create the drone object and pair to CoDrone Mini. Next, create a for loop that will run three times.
In the loop, create variables that will get a random number between 0 and 255 for red, blue, and green. Those three numbers are combined together to change the LED’s color. For example, if your program returned RGB values of 13, 246, and 197, your CoDrone Mini’s LED would turn aqua.
Next, have your drone take off, wait briefly, and then return the red, green, and blue random numbers with a brightness of 100. This should change the color of your drone’s LED. After that, have the drone land.
Try this program out, and once you see what happens, once you get it working, try to add a random value for brightness as well!
from random import randint
drone = CoDrone_mini.CoDrone()
for i in range(3):
red = randint(0,255)
blue = randint(0,255)
green = randint(0,255)