Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. import MotorBridge
  2. import time
  3.  
  4. MotorName        = 1
  5. MotorName        = 2
  6. ClockWise        = 1
  7. CounterClockWise = 2
  8. PwmDuty          = 90
  9. Frequency        = 1000
  10.  
  11. if __name__=="__main__":
  12.     motor = MotorBridge.MotorBridgeCape()
  13.     motor.DCMotorInit(1, 1000)
  14.     motor.DCMotorInit(2, 1000)
  15.     for i in range(1, 51):
  16.         motor.DCMotorMove(1, 1, 90)
  17.         motor.DCMotorMove(2, 1, 90)
  18.  
  19. #Making a U-Shape in the lawn
  20. #Left motor on chassis goes while the right motor ccw
  21.     motor = MotorBridge.MotorBridgeCape()
  22.     motor.DCMotorInit(1, 1000)
  23.     motor.DCMotorInit(2, 1000)
  24.     for i in range(1, 3):
  25.         motor.DCMotorMove(1, 1, 90)
  26.         motor.DCMotorMove(2, 2, 90)
  27.  
  28. #All Flanks...Straight Ahead!
  29.     motor = MotorBridge.MotorBridgeCape()
  30.     motor.DCMotorInit(1, 1000)
  31.     motor.DCMotorInit(2, 1000)
  32.     for i in range(1, 51):
  33.         motor.DCMotorMove(1, 1, 90)
  34.         motor.DCMotorMove(2, 1, 90)
  35.  
  36. #Make another U-Turn but this time, motors go in the opposite direction!
  37.     motor = MotorBridge.MotorBridgeCape()
  38.     motor.DCMotorInit(1, 1000)
  39.     motor.DCMotorInit(2, 1000)
  40.     for i in range(1, 3):
  41.         motor.DCMotorMove(1, 2, 90)
  42.         motor.DCMotorMove(2, 1, 90)
  43.  
  44. #Straight Ahead
  45.     motor = MotorBridge.MotorBridgeCape()
  46.     motor.DCMotorInit(1, 1000)
  47.     motor.DCMotorInit(2, 1000)
  48.     for i in range(1, 51):
  49.         motor.DCMotorMove(1, 1, 90)
  50.         motor.DCMotorMove(2, 1, 90)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement