-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserialclient.py
More file actions
35 lines (31 loc) · 757 Bytes
/
Copy pathserialclient.py
File metadata and controls
35 lines (31 loc) · 757 Bytes
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
import serial
import pyautogui
# COM CONNECTION
ser = serial.Serial(
port='COM3',\
baudrate=115200,\
parity=serial.PARITY_NONE,\
stopbits=serial.STOPBITS_ONE,\
bytesize=serial.EIGHTBITS,\
timeout=1000
)
# COM DETECTION & MOUSE
while True:
result = str(ser.readline())
up = str('U')
down = str('D')
left = str('L')
right = str('R')
click = str('C')
crash = str('CS')
if up in result:
pyautogui.moveRel(0,-50, duration = 0.1)
if down in result:
pyautogui.moveRel(0,50, duration = 0.1)
if left in result:
pyautogui.moveRel(-50,0, duration = 0.1)
if right in result:
pyautogui.moveRel(50,0, duration = 0.1)
if click in result:
pyautogui.press('space')
#pyautogui.click(pyautogui.position())