-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrobot2.py
More file actions
65 lines (57 loc) · 1.22 KB
/
robot2.py
File metadata and controls
65 lines (57 loc) · 1.22 KB
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
import RPi.GPIO as gpio
import time
def init():
gpio.setmode(gpio.BOARD)
gpio.setup(7, gpio.OUT)
gpio.setup(11, gpio.OUT)
gpio.setup(13, gpio.OUT)
gpio.setup(15, gpio.OUT)
def forward(tf):
init()
gpio.output(7, False)
gpio.output(11, True)
gpio.output(13, True)
gpio.output(15, False)
time.sleep(tf)
gpio.cleanup()
def reverse(tf):
init()
gpio.output(7, True)
gpio.output(11, False)
gpio.output(13, False)
gpio.output(15, True)
time.sleep(tf)
gpio.cleanup()
def turn_left(tf):
init()
gpio.output(7, True)
gpio.output(11, True)
gpio.output(13, True)
gpio.output(15, False)
time.sleep(tf)
gpio.cleanup()
def turn_right(tf):
init()
gpio.output(7, False)
gpio.output(11, True)
gpio.output(13, False)
gpio.output(15, False)
time.sleep(tf)
gpio.cleanup()
def pivot_left(tf):
init()
gpio.output(7, True)
gpio.output(11, False)
gpio.output(13, True)
gpio.output(15, False)
time.sleep(tf)
gpio.cleanup()
def pivot_right(tf):
init()
gpio.output(7, False)
gpio.output(11, True)
gpio.output(13, False)
gpio.output(15, True)
time.sleep(tf)
gpio.cleanup()
pivot_right(1)