from controller import Robot

robot = Robot()
TimeStep = 32

# Color sensor initialization
colorSensor = robot.getDevice("colour_sensor")
colorSensor.enable(TimeStep)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# MAIN CODE

while robot.step(TimeStep) != -1:
    image = colorSensor.getImage()
    r = colorSensor.imageGetRed(image, 1, 0, 0)
    g = colorSensor.imageGetGreen(image, 1, 0, 0)
    b = colorSensor.imageGetBlue(image, 1, 0, 0)
    print("Red:",r,"Green:",g,"Blue:",b)