MotorHat4Pi

javadoc

MotorHat4Pi is a motor connected to the AdafruitMotorHat4Pi driver board that can be used on the Raspberry PI. It can drive 4 DC motors ( implemented in mrl ) or two stepper motors ( yet to be implemented ).

https://www.adafruit.com/product/2348

To use the motor you need thee services running on the PI.

1. The RasPi service. http://myrobotlab.org/service/RasPi

2. The AdafruitMotorHat4Pi service. It represents the HAT. http://myrobotlab.org/service/AdafruitMotorHat4Pi

3. One to four of this service. One for each motor.

Examples:


#file : service/MotorHat4Pi.py edit raw
# Start the services needed
raspi = Runtime.start("raspi","RasPi")
hat = Runtime.start("hat","AdafruitMotorHat4Pi")
m1 = Runtime.start("m1","MotorHat4Pi")
# Attach the HAT to i2c bus 1 and address 0x60
hat.attach("raspi","1","0x60")
# Use the M1 motor port and attach the motor to the hat
m1.setMotor("M1")
m1.attach("hat")
# Now everything is wired up and we run a few tests
# Full speed forward
m1.move(1) 
sleep(3)
# half speed forward
m1.move(.5)
sleep(3)
# Move backward at 60% speed
m1.move(-.6)
sleep(3)
# Stop
m1.move(0)
# Now you should be able to use the GUI or a script to control the motor