RGB LED While Loops

# Module Import

import LocoIOT

import time


# Class Instances Creation

loco_iot = LocoIOT.LocoIOT()

msg = LocoIOT.IOT_Codes()


# Initiate Connection to the Microcontroller

loco_iot.connect()


# Enable RGB Hardware Configuration

loco_iot.enable(msg.SUBTYPE_RGB)


#Dictionary

colors = {

"red" : [255, 0, 0] ,

"green" : [0, 255, 0] ,

"blue": [0, 0, 255] ,

"orange" : [255, 125, 0] ,

"magenta" : [255, 0, 255] ,

"cyan" : [0, 255, 255] ,

}

# Start Listening for Control/Request Messages

loco_iot.start()


# Infinite Loop: Press cancel to end the loop.

while True:

for key in colors.keys():

# Set Colors

loco_iot.setData(msg.SUBTYPE_RGB, colors[key])

time.sleep(1)

print(key)

# Close Connection to the Microcontroller

loco_iot.close()