One of the ways you can see return values with your CoDrone EDU 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 EDU, time, and random libraries, and then create the drone object and pair to CoDrone EDU. 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 EDU’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 codrone_edu.drone import *
drone = Drone()
for i in range(3):
red = random.randint(0,255)
blue = random.randint(0,255)
green = random.randint(0,255)