----> http://www.adafruit.com/products/1438 ''' from Adafruit_MotorShield import Adafruit_MotorShield from Adafruit_StepperMotor import Adafruit_StepperMotor import time # Create the motor shield object with the default I2C address AFMS = Adafruit_MotorShield() # Or, create it with a different I2C address (say for stacking) # AFMS = Adafruit_MotorShield(0x61); # Connect a stepper motor with 200 steps per revolution (1.8 degree) # to motor port #2 (M3 and M4) myMotor = AFMS.getStepper(200, 2) AFMS.begin() # create with the default frequency 1.6KHz #AFMS.begin(1000); // OR with a different frequency, say 1KHz myMotor.setSpeed(10); # 10 rpm try: while (True): print "Single coil steps" myMotor.step(100, Adafruit_StepperMotor.FORWARD, Adafruit_StepperMotor.SINGLE); myMotor.step(100, Adafruit_StepperMotor.BACKWARD, Adafruit_StepperMotor.SINGLE); print "Double coil steps" myMotor.step(100, Adafruit_StepperMotor.FORWARD, Adafruit_StepperMotor.DOUBLE)
from Adafruit_MotorShield import Adafruit_MotorShield from Adafruit_StepperMotor import Adafruit_StepperMotor from sys import argv import time # Create the motor shield object with the default I2C address AFMS = Adafruit_MotorShield() # Or, create it with a different I2C address (say for stacking) # AFMS = Adafruit_MotorShield(0x61); # Connect a stepper motor with 200 steps per revolution (1.8 degree) # to motor port #2 (M3 and M4) myMotor = AFMS.getStepper(200, 1) AFMS.begin() # create with the default frequency 1.6KHz #AFMS.begin(1100); #// OR with a different frequency, say 1KHz myMotor.setSpeed(4000) # 10 rpm try: myMotor.step( int(argv[1]) * 200, Adafruit_StepperMotor.FORWARD, Adafruit_StepperMotor.DOUBLE) except KeyboardInterrupt: myMotor.release() #remove current flow accross motor myMotor.release()
exit(1) shieldID = int(sys.argv[1], 16) motorID = int(sys.argv[2]) stepMode = sys.argv[3] direction = sys.argv[4] speed = int(sys.argv[5]) step = int(sys.argv[6]) # Create the motor shield object with the I2C address AFMS = Adafruit_MotorShield(shieldID) # Connect a stepper motor with 200 steps per revolution (1.8 degree) # to motor port #2 (M3 and M4) myMotor = AFMS.getStepper(200, motorID) AFMS.begin() # create with the default frequency 1.6KHz #AFMS.begin(1000); // OR with a different frequency, say 1KHz myMotor.setSpeed(speed); # 10 rpm try: myMotor.step(step, STEP_DIRECTION[direction], STEP_MODE[stepMode]) myMotor.release() print "OK" except KeyboardInterrupt: myMotor.release() print "Clean " except: print "Unexpected error:", sys.exc_info()[0]