I'm using a raspberry pi 4b and it's running Raspbian 10 (Buster). I have a Geekworm Pi Motor HAT Full function Robot Expansion Board. I'm using the GitHub code: Raspi-MotorHat-master. I'm using Python version 3.7. This is the link to the GitHub library I'm using: https://github.com/Alictronix/Raspi-MotorHat
I'm trying to build a simple robot and drive 2 DC motors. I'm trying to get 4WDTEST.py
to work. I keep getting this error in Raspi_MotorHAT.py:
File "/home/xxxxx/PythonCode/Raspi-MotorHat-master/Raspi_MotorHAT.py", line 213, in setSpeed
self.MC._pwm.setPWM(self.PWMpin, 0, speed*16)
AttributeError: 'Raspi_DCMotor' object has no attribute 'PWMpin'
This is the function where the code is failing:
def setSpeed(self, speed):
if (speed < 0):
speed = 0
if (speed > 255):
speed = 255
self.MC._pwm.setPWM(self.PWMpin, 0, speed*16)
I assume this code was done for Python 2.7 or earlier. I can't figure out how to get past this error. I've looked at the Adafruit-Motor-HAT-Python-Library-master code and it is the same. I assume this code works. Any help would be greatly appreciated.