Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(leftMotorSpeed > 0 && rightMotorSpeed > 0 )
- {
- // set motor speeds using the two motor speed variables above
- set_motors_position(leftMotorSpeed, rightMotorSpeed);
- }
- else
- {
- set_motors_negative(leftMotorSpeed, rightMotorSpeed);
- }
- }
- void set_motors_negative(int motor1speed, int motor2speed)
- {
- if (motor1speed > M1_maksimum_speed ) motor1speed = M1_maksimum_speed;
- if (motor2speed > M2_maksimum_speed ) motor2speed = M2_maksimum_speed;
- if (motor1speed < 0)
- {
- motor1speed *=-1
- motor1.setSpeed(motor1speed);
- motor1.run(BACKWARD);
- }
- else{
- motor2speed *=-1
- motor2.setSpeed(motor2speed);
- motor2.run(BACKWARD);
- }
- if (motor2speed < 0)
- {
- motor2speed *= -1;
- motor2.setSpeed(motor2speed)
- motor2.run(BACKWARD);
- }
- else
- {
- motor1speed *=-1
- motor1.setSpeed(motor1speed);
- motor1.run(BACKWARD);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement