Created
January 3, 2014 02:43
-
-
Save adammck/8231667 to your computer and use it in GitHub Desktop.
Flash the LED on a Dynamixel servo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import time | |
| import optparse | |
| import dynamixel | |
| if __name__ == "__main__": | |
| parser = optparse.OptionParser() | |
| parser.add_option("-p", "--port", help="Serial port", default="/dev/tty.usbserial-A9ITPZVR") | |
| parser.add_option("-b", "--baud", help="Baud rate", default="1000000") | |
| parser.add_option("-i", "--servo-id", dest="servo_id", help="Servo ID", default="1") | |
| (options, args) = parser.parse_args() | |
| serial = dynamixel.SerialStream(port=options.port, baudrate=options.baud, timeout=1) | |
| network = dynamixel.DynamixelNetwork(serial) | |
| servo = dynamixel.Dynamixel(int(options.servo_id), network) | |
| try: | |
| while True: | |
| servo.led = not servo.led | |
| time.sleep(0.25) | |
| except KeyboardInterrupt: | |
| servo.led = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment