This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
servoclass-py [2015/04/30 08:41] zoza |
servoclass-py [2015/04/30 08:42] (current) zoza |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== servoclass.py ====== | ====== servoclass.py ====== | ||
- | external functions for different LED behaviours | + | external functions for motors control |
<code python> | <code python> | ||
#!/usr/bin/env python | #!/usr/bin/env python | ||
Line 12: | Line 12: | ||
try: | try: | ||
portmotor = glob.glob("/dev/arduino-motors")[0] # as assigned in udev rules /etc/udev/rules.d ; http://hackaday.com/2009/09/18/how-to-write-udev-rules/ | portmotor = glob.glob("/dev/arduino-motors")[0] # as assigned in udev rules /etc/udev/rules.d ; http://hackaday.com/2009/09/18/how-to-write-udev-rules/ | ||
- | except IndexError: | ||
except IndexError: | except IndexError: | ||
portmotor = glob.glob("/dev/ttyUSB0")[0] # fall back to a default USB address | portmotor = glob.glob("/dev/ttyUSB0")[0] # fall back to a default USB address | ||
Line 19: | Line 18: | ||
### set up serial baud rate | ### set up serial baud rate | ||
sermotor = serial.Serial(portmotor, 9600, timeout=1) | sermotor = serial.Serial(portmotor, 9600, timeout=1) | ||
- | # serled = serial.Serial(portled, 9600, timeout=1) | ||
class Servo: | class Servo: |