Two simple programs to control a motor via LabJack FIO connectors
######################################### motor_test.py ###################################
# LabJack U3 controls motor1 on/off via FIO4
import u3
from easyU3 import (u3setup,analogIn0,analogIn1,
dac0out,dac1out,digitalIn2,digitalIn3,
FIO4on,FIO4off,FIO5on,FIO5off,FIO6on,FIO6off,FIO7on,FIO7off,
temperatureC,temperatureF,LED)
d = u3.U3() # Opens first found U3 over USB
u3setup(d)
print "Enter g to make motor 1 go, s to make it stop, q to quit"
while True:
command = raw_input("Enter g, s or q: ")
if command == "g":
print "go"
FIO4on(d)
elif command == "s":
print "stop"
FIO4off(d)
elif command == "q":
break
######################################### motor_test2.py ###################################
# LabJack U3 controls motor2 forward/off/backward via FIO6 and FIO7
import u3
from easyU3 import (u3setup,analogIn0,analogIn1,
dac0out,dac1out,digitalIn2,digitalIn3,
FIO4on,FIO4off,FIO5on,FIO5off,FIO6on,FIO6off,FIO7on,FIO7off,
temperatureC,temperatureF,LED)
d = u3.U3() # Opens first found U3 over USB
u3setup(d)
print "Enter f to make motor 2 go forward, b to go backwards, s to make it stop, q to quit"
while True:
command = raw_input("Enter f, b, s or q: ")
if command == "f":
print "go forward"
FIO6on(d)
FIO7off(d)
if command == "b":
print "go backward"
FIO6off(d)
FIO7on(d)
elif command == "s":
print "stop"
FIO6off(d)
FIO7off(d)
elif command == "q":
break