Replies: 6 comments 2 replies
-
In general, you can use a negative speed to make the motor run in the negative direction (and you can set the positive direction to clockwise or counterclockwise when you create the motor object). |
Beta Was this translation helpful? Give feedback.
-
Thanks for your help. |
Beta Was this translation helpful? Give feedback.
-
I've now tried this and it's spinning in the same direction even if I change from positive to negative. |
Beta Was this translation helpful? Give feedback.
-
I defined some of the code to make it easier. from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch
from pybricks.tools import hub_menu
from pybricks.tools import multitask, run_task
from pybricks.tools import hub_menu
hub = PrimeHub()
left_motor = Motor(Port.A, Direction.CLOCKWISE)
right_motor = Motor(Port.B, Direction.COUNTERCLOCKWISE)
f_motor = Motor(Port.D)
b_motor = Motor(Port.C)
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=128)
drive = drive_base.straight
turn = drive_base.turn
curve = drive_base.curve
backM = b_motor.run_angle
frontM = f_motor.run_angle
speed = drive_base.settings #slow=(100, 375, 75, 375) #fast=(850, 1000, 850, 1000)
#Start of Code
speed(500, 500, 250, 250)
drive(470)
wait(200)
turn(38.75)
speed(400, 400, 300, 300)
drive(400)
frontM(1000, 102)
frontM(1000, 25)
frontM(70, -125)
speed(850, 1000, 850, 1000)
drive(-260)
turn(20)
backM(1000, -110)
turn(97)
drive(750) |
Beta Was this translation helpful? Give feedback.
-
Sorry wrong code from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch
from pybricks.tools import hub_menu
from pybricks.tools import multitask, run_task
from pybricks.tools import hub_menu
hub = PrimeHub()
left_motor = Motor(Port.A, Direction.CLOCKWISE)
right_motor = Motor(Port.B, Direction.COUNTERCLOCKWISE)
f_motor = Motor(Port.D)
b_motor = Motor(Port.C)
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=128)
drive = drive_base.straight
turn = drive_base.turn
curve = drive_base.curve
backM = b_motor.run_angle
frontM = f_motor.run_angle
speed = drive_base.settings #slow=(100, 375, 75, 375) #fast=(850, 1000, 850, 1000)
#Start of Code
speed(500, 500, 250, 250)
drive(470)
wait(200)
turn(38.75)
speed(400, 400, 300, 300)
drive(400)
f_motor.run_time(1000, 1)
frontM(70, -125)
speed(850, 1000, 850, 1000)
drive(-260)
turn(20)
backM(1000, -110)
turn(97)
drive(750) |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for that, we will be able to finish to code now. |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm recently new to pybricks and have come to a roadblock. I'm trying to get mt FLL robot to move its arms using time instead of angle because of issues, I have gotten it to work but need the motor to run in the opposite direction. Any ideas of how to do this?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions