Exercise Servo
# 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 Servo Hardware Configuration
loco_iot.enable(msg.SUBTYPE_SERVO)
# Start Listening for Control/Request Messages
loco_iot.start()
# Infinite Loop: Press cancel to end the loop.
while True:
# Set Servo Angle, From 0 to 180
loco_iot.setData(msg.SUBTYPE_SERVO, [0])
servo_angle = input("Enter a number between 0 and 180")
servo_angle_int = int(servo_angle)
loco_iot.setData(msg.SUBTYPE_SERVO, [servo_angle_int])
print(servo_angle_int)
# Arbitrary Delay
time.sleep(1)
# Close Connection to the Microcontroller
loco_iot.close()