def right_turn(speed, running_time): setup.leftmotor(setup.forward0) GPIO.output(setup.Motor_Left_PWM, GPIO.HIGH) GPIO.output(setup.Motor_Right_PWM, GPIO.LOW) setup.Left_Pwm.ChangeDutyCycle(speed) setup.Right_Pwm.ChangeDutyCycle(0) time.sleep(running_time)
def go_forward(speed): ''' move forward speed is motor move speed(0~100)''' # set left and right motor to move forward setup.leftmotor(setup.forward0) setup.rightmotor(setup.forward0) # set speed of motors to move forward setup.Left_Pwm.ChangeDutyCycle(speed) setup.Right_Pwm.ChangeDutyCycle(speed)
def go_forward_any(speed): setup.leftmotor(setup.forward0) GPIO.output(setup.Motor_Left_PWM, GPIO.HIGH) setup.rightmotor(setup.forward0) GPIO.output(setup.Motor_Right_PWM, GPIO.HIGH) setup.Left_Pwm.ChangeDutyCycle(speed) setup.Right_Pwm.ChangeDutyCycle(speed)
def go_forward_any(speed): setup.leftmotor(forward0) GPIO.output(MotorLeft_PWM, GPIO.HIGH) setup.rightmotor(forward0) GPIO.output(MotorRight_PWM, GPIO.HIGH) LeftPwm.ChangeDutyCycle(speed) RightPwm.ChangeDutyCycle(speed)
def go_forward(speed, running_time): setup.leftmotor(setup.forward0) GPIO.output(setup.Motor_Left_PWM, GPIO.HIGH) setup.rightmotor(setup.forward0) GPIO.output(setup.Motor_Right_PWM, GPIO.HIGH) setup.Left_Pwm.ChangeDutyCycle(speed) setup.Right_Pwm.ChangeDutyCycle(speed) time.sleep(running_time) stop()
def go_forward(speed, running_time): setup.leftmotor(forward0) GPIO.output(MotorLeft_PWM, GPIO.HIGH) setup.rightmotor(forward0) GPIO.output(MotorRight_PWM, GPIO.HIGH) LeftPwm.ChangeDutyCycle(speed) RightPwm.ChangeDutyCycle(speed) time.sleep(running_time) stop()
def rightRoundTurn(speed_high, speed_low): setup.rightmotor(setup.forward0) setup.leftmotor(setup.forward0) GPIO.output(setup.Motor_Left_PWM,GPIO.HIGH) GPIO.output(setup.Motor_Right_PWM,GPIO.HIGH) setup.Left_Pwm.ChangeDutyCycle(speed_low) setup.Right_Pwm.ChangeDutyCycle(speed_high)
def right_turn2(speed, running_time): '''Move the left wheel forward and Turn the right wheel backward to right turn speed is turn speed running_time is the time the wheels move''' # set the left motor and pwm to move forward setup.leftmotor(setup.forward0) GPIO.output(setup.Motor_Left_PWM,GPIO.HIGH) # set the right motor and pwm to move backward setup.rightmotor(setup.backward0) GPIO.output(setup.Motor_Right_PWM,GPIO.LOW) # set the speed of the left and right motor setup.Left_Pwm.ChangeDutyCycle(speed) setup.Right_Pwm.ChangeDutyCycle(speed) # set the running time of the motors to move time.sleep(running_time)
def rightSwingTurn(speed, running_time): # set the left motor to go fowrard setup.leftmotor(setup.forward0) # set the left motor pwm to be ready to go forward GPIO.output(setup.Motor_Left_PWM, GPIO.HIGH) # set the right motor pwm to be ready to stop # Turn Off Right PWM GPIO.output(setup.Motor_Right_PWM, GPIO.LOW) # set the speed of the left motor to go fowrard setup.Left_Pwm.ChangeDutyCycle(speed) # set the speed of the right motor to stop setup.Right_Pwm.ChangeDutyCycle(0) # set the running time of the left motor to go fowrard time.sleep(running_time)
def rightRoundTurn(speed_high, speed_low): # set the right motor to go fowrard setup.rightmotor(setup.forward0) # set the left motor to go fowrard setup.leftmotor(setup.forward0) # set the left motor pwm to be ready to go forward GPIO.output(setup.Motor_Left_PWM, GPIO.HIGH) # set the right motor pwm to be ready to stop # Turn Off Right PWM GPIO.output(setup.Motor_Right_PWM, GPIO.HIGH) # set the speed of the left motor to go fowrard setup.Left_Pwm.ChangeDutyCycle(speed_low) # set the speed of the right motor to stop setup.Right_Pwm.ChangeDutyCycle(speed_high)
def right_turn(speed, running_time): '''Only the left wheel move forward to right turn speed is turn speed running_time is the time the wheel move''' # set the left motor to go fowrard setup.leftmotor(setup.forward0) # set the left motor pwm to be ready to go forward GPIO.output(setup.Motor_Left_PWM,GPIO.HIGH) # set the right motor pwm to be ready to stop # Turn Off Right PWM GPIO.output(setup.Motor_Right_PWM,GPIO.LOW) # set the speed of the left motor to go fowrard setup.Left_Pwm.ChangeDutyCycle(speed) # set the speed of the right motor to stop setup.Right_Pwm.ChangeDutyCycle(0) # set the running time of the left motor to go fowrard time.sleep(running_time)
def go_forward(speed): setup.leftmotor(setup.forward0) setup.rightmotor(setup.forward0) setup.Left_Pwm.ChangeDutyCycle(speed) setup.Right_Pwm.ChangeDutyCycle(speed)