-
Notifications
You must be signed in to change notification settings - Fork 0
/
otto-control.py
57 lines (44 loc) · 1.05 KB
/
otto-control.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import RPi.GPIO as GPIO
from flask import Flask, render_template, request
import datetime
app = Flask(__name__)
from Tkinter import *
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
pwm = GPIO.PWM(18, 100)
#pwm.start(5)
# root = Tk()
# root.wm_title('Servo Control')
# app = App(root)
# root.geometry("200x50+0+0")
# root.mainloop()
@app.route("/")
def main():
pwm.start(0)
now = datetime.datetime.now()
timeString = now.strftime("%Y-%m-%d %H:%M")
templateData = {
'title' : 'HELLO!',
'time': timeString
}
return render_template('main.html', **templateData)
@app.route("/forward")
def forward():
pwm.start(50)
templateData = {
'value': '50',
'title': 'FORWARD'
}
return render_template('dir.html')
@app.route("/backward")
def backward():
pwm.start(2)
templateData = {
'value': '2',
'title': 'BACKWARD'
}
return render_template('dir.html')
if __name__ == "__main__":
app.run(host='0.0.0.0', port=80, debug=True)