This is a test script for the Adafruit assembled Motor Shield for Arduino v2 It won't work with v1.x motor shields! Only for the v2's with built in PWM control For use with the Adafruit Motor Shield v2 ----> 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):
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()
This is a test script for the Adafruit assembled Motor Shield for Arduino v2 It won't work with v1.x motor shields! Only for the v2's with built in PWM control For use with the Adafruit Motor Shield v2 ----> http://www.adafruit.com/products/1438 ''' from Adafruit_MotorShield import Adafruit_MotorShield from Adafruit_DCMotor import Adafruit_DCMotor 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); # Select which 'port' M1, M2, M3 or M4. In this case, M1 myMotor = AFMS.getMotor(1) AFMS.begin() # create with the default frequency 1.6KHz #AFMS.begin(1000); // OR with a different frequency, say 1KHz # Set the speed to start, from 0 (off) to 255 (max speed) myMotor.setSpeed(150); # 10 rpm myMotor.run(Adafruit_DCMotor.FORWARD) # turn on motor myMotor.run(Adafruit_DCMotor.RELEASE)