Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jim #592

Open
robjim418 opened this issue Jul 14, 2023 · 0 comments
Open

Jim #592

robjim418 opened this issue Jul 14, 2023 · 0 comments

Comments

@robjim418
Copy link

I #!/usr/bin/python

import PiMotor
import time
import RPi.GPIO as GPIO

#Name of Individual MOTORS
m1 = PiMotor.Motor("MOTOR1",1)
m2 = PiMotor.Motor("MOTOR2",1)
m3 = PiMotor.Motor("MOTOR3",1)
m4 = PiMotor.Motor("MOTOR4",1)

#To drive all motors together
motorAll = PiMotor.LinkedMotors(m1,m2,m3,m4)

#Names for Individual Arrows
ab = PiMotor.Arrow(1)
al = PiMotor.Arrow(2)
af = PiMotor.Arrow(3)
ar = PiMotor.Arrow(4)

##This segment drives the motors in the direction listed below:

forward and reverse takes speed in percentage(0-100)

try:
while True:
#-----------To Drive the Motors Forward------------#
print("Robot Moving Forward ")
af.on()
motorAll.forward(100)
time.sleep(5)
#--------------------------------------------------#

#-----------To Drive the Motors backwards------------#
print("Robot Moving Backward ")
af.off()
ab.on()
motorAll.reverse(100)
time.sleep(5)
#--------------------------------------------------#

#-----------To Drive the Motors Left---------------#
print("Robot Moving Left ")
ab.off()
al.on()
m1.stop()
m2.stop()
m3.forward(100)
m4.forward(100)
time.sleep(5)
#--------------------------------------------------#

#----------To Drive the Motors Right---------------#
print("Robot Moving Right ")
ar.on()
al.off()
m1.forward(100)
m2.forward(100)
m3.stop()
m4.stop()
time.sleep(5)
#-------------------------------------------------#

#---------To Stop the Motors----------------------#
print("Robot Stop ")
al.off()
af.off()
ar.off()
motorAll.stop()
time.sleep(5)
#-------------------------------------------------#

except KeyboardInterrupt:
GPIO.cleanup()

am using a MotorShield on an RPi 3B with the following code . I get error PiMotor has no attribute "Motor"
Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant