I am using the Dc+Stepper Motor Hat, and trying to run the simplest test described in:
https://learn.adafruit.com/adafruit-dc- ... -dc-motors
During the execution I get the following error:
pi@pi:~/sw/Adafruit-Motor-HAT-Python-Library/examples $ python DCTest_M1.py
Traceback (most recent call last):
File "DCTest_M1.py", line 8, in <module>
mh = Adafruit_MotorHAT(addr=0x60)
File "build/bdist.linux-armv6l/egg/Adafruit_MotorHAT/Adafruit_MotorHAT_Motors.py", line 231, in __init__
File "build/bdist.linux-armv6l/egg/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py", line 59, in __init__
File "build/bdist.linux-armv6l/egg/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py", line 95, in setAllPWM
File "build/bdist.linux-armv6l/egg/Adafruit_GPIO/I2C.py", line 114, in write8
File "build/bdist.linux-armv6l/egg/Adafruit_PureIO/smbus.py", line 236, in write_byte_data
IOError: [Errno 5] Input/output error
Do you know what is the problem?
Best Regards
Here is the whole source code:
Code: Select all
Adafruit_MotorHAT import Adafruit_MotorHAT, Adafruit_DCMotor
import time
import atexit
# create a default object, no changes to I2C address or frequency
mh = Adafruit_MotorHAT(addr=0x60)
# recommended for auto-disabling motors on shutdown!
def turnOffMotors():
mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
mh.getMotor(2).run(Adafruit_MotorHAT.RELEASE)
mh.getMotor(3).run(Adafruit_MotorHAT.RELEASE)
mh.getMotor(4).run(Adafruit_MotorHAT.RELEASE)
atexit.register(turnOffMotors)
################################# DC motor test!
myMotor = mh.getMotor(1)
# set the speed to start, from 0 (off) to 255 (max speed)
myMotor.setSpeed(150)
myMotor.run(Adafruit_MotorHAT.FORWARD);
# turn on motor
myMotor.run(Adafruit_MotorHAT.RELEASE);
while (True):
print("Forward! ")
myMotor.run(Adafruit_MotorHAT.FORWARD)
print("\tSpeed up...")
for i in range(255):
myMotor.setSpeed(i)
time.sleep(0.01)
print("\tSlow down...")
for i in reversed(range(255)):
myMotor.setSpeed(i)
time.sleep(0.01)
print("Backward! ")
myMotor.run(Adafruit_MotorHAT.BACKWARD)
print("\tSpeed up...")
for i in range(255):
myMotor.setSpeed(i)
time.sleep(0.01)
print("\tSlow down...")
for i in reversed(range(255)):
myMotor.setSpeed(i)
time.sleep(0.01)
print("Release")
myMotor.run(Adafruit_MotorHAT.RELEASE)
time.sleep(1.0)