mirror of
https://github.com/blw1138/MercurySim.git
synced 2025-12-17 08:38:12 +00:00
17 lines
434 B
Python
17 lines
434 B
Python
import serial
|
|
|
|
|
|
class MercuryController:
|
|
def __init__(self, port, baud):
|
|
self.serial = serial.Serial(port, baud)
|
|
self.serial.flushInput()
|
|
|
|
def led_on(self, pin):
|
|
self.serial.write("LED {} on".format(pin))
|
|
|
|
def led_off(self, pin):
|
|
self.serial.write("LED {} off".format(pin))
|
|
|
|
def set_servo_percent(self, servo, percent):
|
|
self.serial.write("servo {0} {1}".format(servo, percent))
|