Advertisement
silver2row

MBC/FLASK

Jan 27th, 2020
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1. from MotorBridgeI import MotorBridgeCape
  2. from flask import Flask, render_template
  3. import time
  4.  
  5. # DC Motors
  6. MotorName1         = 1
  7. MotorName2         = 2
  8. MotorName3         = 3
  9. MotorName4         = 4
  10.  
  11. ClockWise          = 1
  12. CounterClockWise   = 2
  13. PwmDuty            = 100
  14. Frequency          = 1000
  15.  
  16. # Servo Motors
  17. #ServoName1         = 1
  18. #ServoName6         = 6
  19.  
  20. #Frequency2         = 50
  21. #Angle1             = 0
  22. #Angle2             = 45
  23. #Angle3             = 90
  24. #Angle4             = 135
  25. #Angle5             = 180
  26.  
  27. app = Flask(__name__)
  28.  
  29. @app.route("/")
  30. @app.route("/<state>")
  31.  
  32. def updates(state=None):
  33.     time.sleep(0.5)
  34.     motor = MotorBridgeCape()
  35.     motor.DCMotorInit(MotorName1, Frequency)
  36.     motor.DCMotorInit(MotorName2, Frequency)
  37.     motor.DCMotorInit(MotorName3, Frequency)
  38.     motor.DCMotorInit(MotorName4, Frequency)
  39.     #motor.ServoInit(ServoName1, Frequency2)
  40.     #motor.ServoInit(ServoName6, Frequency2)
  41.  
  42.     # while True:
  43.     if state == "F":
  44.         motor.DCMotorMove(MotorName1, ClockWise, PwmDuty)
  45.         motor.DCMotorMove(MotorName2, ClockWise, PwmDuty)
  46.         motor.DCMotorMove(MotorName3, ClockWise, PwmDuty)
  47.         motor.DCMotorMove(MotorName4, ClockWise, PwmDuty)
  48.  
  49.      template_data = {
  50.         "title" : state,
  51.     }
  52.     return render_template("ServoKing.html", **template_data)
  53.  
  54. if __name__ == "__main__":
  55.     app.run(host="0.0.0.0", port=5000, debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement