def just_go_backward(speed): # set left motor to go backward by GPIO and motor_module setup_base.motor(setup_base.backward0, setup_base.Motor_Left_A, setup_base.Motor_Left_B) GPIO.output(setup_base.Motor_Left_PWM, GPIO.HIGH) # set right motor to go backward by GPIO and motor_module setup_base.motor(setup_base.backward1, setup_base.Motor_Right_A, setup_base.Motor_Right_B) GPIO.output(setup_base.Motor_Right_PWM, GPIO.HIGH) # set left and right Pwm to get speed setup_base.Left_Pwm.ChangeDutyCycle(speed) setup_base.Right_Pwm.ChangeDutyCycle(speed)
def left_PointTurn(speed, running_time): # set the left motor and pwm to go backward setup_base.motor(setup_base.bakward0, setup_base.Motor_Left_A, setup_base.Motor_Left_B) GPIO.output(setup_base.Motor_Left_PWM, GPIO.LOW) # set the right motor and pwm to go forward setup_base.motor(setup_base.forward1, setup_base.Motor_Right_A, setup_base.Motor_Right_B) GPIO.output(setup_base.Motor_Right_PWM, GPIO.HIGH) # set the speed of the left and right motor to go setup_base.Left_Pwm.ChangeDutyCycle(speed) setup_base.Right_Pwm.ChangeDutyCycle(speed) # set the running time of the left and right motor time.sleep(running_time)
def left_SwingTurn(speed, running_time): # set the left motor pwm to stop = turn off GPIO.output(setup_base.Motor_Left_PWM, GPIO.LOW) # set the right motor and pwm to go forward setup_base.motor(setup_base.forward0, setup_base.Motor_Right_A, setup_base.Motor_Right_B) GPIO.output(setup_base.Motor_Right_PWM, GPIO.HIGH) # set the speed of the left motor to stop setup_base.Left_Pwm.ChangeDutyCycle(0) # set the spedd of the right motor to go forward setup_base.Right_Pwm.ChangeDutyCycle(speed) # set the running tiem of the right motor to go forward time.sleep(running_time)
def go_forward(speed, running_time): # set left motor to go forward by GPIO and motor_module setup_base.motor(setup_base.forward0, setup_base.Motor_Left_A, setup_base.Motor_Left_B) GPIO.output(setup_base.Motor_Left_PWM, GPIO.HIGH) # set right motor to go forward by GPIO and motor_module setup_base.motor(setup_base.forward1, setup_base.Motor_Right_A, setup_base.Motor_Right_B) GPIO.output(setup_base.Motor_Right_PWM, GPIO.HIGH) # set left and right Pwm to get speed setup_base.Left_Pwm.ChangeDutyCycle(speed) setup_base.Right_Pwm.ChangeDutyCycle(speed) # stop motor after running_time time.sleep(running_time) stop()