IOT Exercise Dual LED
IOT LED Dual
# Module Imports
import LocoIOT
import time
# Class Instances Creation
loco_iot = LocoIOT.LocoIOT()
msg = LocoIOT.IOT_Codes()
# Initiate Connection to the Microcontroller
loco_iot.connect()
# Enable Digital Output Hardware Configuration
loco_iot.enable(msg.SUBTYPE_DO_1)
loco_iot.enable(msg.SUBTYPE_DO_2)
# Instruct the Microcontroller to Start Listening for Control/Request Messages
loco_iot.start()
#LED1 switch
on_time_LED1 = 2
off_time_LED1 = .5
#LED2 switch
on_time_LED2 = 3
off_time_LED2 = .5
while True:
loco_iot.setData(msg.SUBTYPE_DO_1, [1])
time.sleep(1)
loco_iot.setData(msg.SUBTYPE_DO_1, [0])
time.sleep(1)
loco_iot.setData(msg.SUBTYPE_DO_2, [1])
time.sleep(1)
loco_iot.setData(msg.SUBTYPE_DO_2, [0])
time.sleep(1)
#Print LED's
print("LED1 on")
print("LED1 off")
print("LED2 on")
print("LED2 off")
# Close Connection to the Microcontroller
loco_iot.close()