-
Notifications
You must be signed in to change notification settings - Fork 0
/
DirectInput.py
55 lines (44 loc) · 1.03 KB
/
DirectInput.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
import serial
import time
import random
import keyboard
import os
from funciones import send
arduino = serial.Serial('COM9', 9600)
time.sleep(2)
vector = [0,0,0,0,0]
time = 0;
n = 0
send(vector, arduino)
while (True):
time +=1
if keyboard.is_pressed('w') and time > 1000 and vector[n] < 100:
vector[n] +=10
time = 0
os.system('cls')
print(vector)
print(n)
send(vector,arduino)
elif keyboard.is_pressed('d') and time > 1000 and n < 4:
n += 1
time = 0
os.system('cls')
print(vector)
print(n)
elif keyboard.is_pressed('a') and time > 1000 and n > 0:
n -= 1
time = 0
os.system('cls')
print(vector)
print(n)
elif keyboard.is_pressed('s') and time > 1000 and vector[n] > 0:
vector[n] -=10
time = 0
os.system('cls')
print(vector)
print(n)
send(vector,arduino)
if keyboard.is_pressed('q'):
send([0,0,0,0,0], arduino)
break
arduino.close()