-
Notifications
You must be signed in to change notification settings - Fork 0
/
slave.py
71 lines (57 loc) · 1.41 KB
/
slave.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
import socket
import os
import subprocess
#import RPi.GPIO as GPIO
import time
#GPIO.setmode(GPIO.BOARD)
'''GPIO.setmode(GPIO.BOARD)
GPIO.setup(2, GPIO.OUT)
GPIO.setup(3, GPIO.OUT)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(17, GPIO.OUT)'''
def right():
GPIO.output(2, GPIO.HIGH)
GPIO.output(3, GPIO.LOW)
GPIO.output(7, GPIO.HIGH)
GPIO.output(17, GPIO.LOW)
time.sleep(0.5)
def left():
GPIO.output(3, GPIO.HIGH)
GPIO.output(2, GPIO.LOW)
GPIO.output(17, GPIO.HIGH)
GPIO.output(7, GPIO.LOW)
time.sleep(0.5)
def back():
GPIO.output(2, GPIO.HIGH)
GPIO.output(3, GPIO.LOW)
GPIO.output(17, GPIO.HIGH)
GPIO.output(7, GPIO.LOW)
time.sleep(0.5)
def forward():
GPIO.output(3, GPIO.HIGH)
GPIO.output(2, GPIO.LOW)
GPIO.output(7, GPIO.HIGH)
GPIO.output(17, GPIO.LOW)
time.sleep(0.5)
s = socket.socket()
host = "172.17.231.167"
port = 9999
s.connect((host, port))
while (True):
data = s.recv(1024)
data = data.decode(("utf-8"))
if (data == 'right'):
#right()
print('right')
# client_response=str(conn.recv(1024),"utf-8")
elif (data == 'left'):
#left()
print('right')
# client_response = str(conn.recv(1024), "utf-8")
elif (data == 'back'):
#back()
print('right')
# client_response = str(conn.recv(1024), "utf-8")
elif(data == 'forward'):
#forward()
print('right')