-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
78 lines (56 loc) · 1.29 KB
/
main.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import BlynkLib
from robot import Robot
robot = Robot()
BLYNK_AUTH = "7PLekS2X0JfhvIuWFDOG86mc5Klh8Jne"
blynk = BlynkLib.Blynk(BLYNK_AUTH)
@blynk.on("V0")
def move_forward(value):
pressed = int(value[0])
if pressed == 1:
robot.move_forward()
else:
robot.stop()
@blynk.on("V1")
def turn_right(value):
pressed = int(value[0])
if pressed == 1:
robot.turn_right()
else:
robot.stop()
@blynk.on("V2")
def move_backward(value):
pressed = int(value[0])
if pressed == 1:
robot.move_backward()
else:
robot.stop()
@blynk.on("V3")
def turn_left(value):
pressed = int(value[0])
if pressed == 1:
robot.turn_left()
else:
robot.stop()
@blynk.on("V4")
def play_sound(value):
pressed = int(value[0])
if pressed == 1:
robot.play_sound()
@blynk.on("V5")
def set_angle(value):
angle = int(value[0])
robot.set_head_angle(angle)
@blynk.on("V6")
def set_red(value):
intensity = int(value[0])
robot.set_eye_color("red", intensity)
@blynk.on("V7")
def set_green(value):
intensity = int(value[0])
robot.set_eye_color("green", intensity)
@blynk.on("V8")
def set_blue(value):
intensity = int(value[0])
robot.set_eye_color("blue", intensity)
while True:
blynk.run()