-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmódulo1.py
64 lines (52 loc) · 1.32 KB
/
módulo1.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
import ComunicacionArduino as ComArd
from time import sleep
import random as rd
def generador():
string=str()
for i in range(0,30,1):
valor=rd.randint(0,25)
string = string + chr(ord('a')+valor)
print('The String generated is: ' + string)
return string
def movesGenerator(NoMoves):
string=str()
for i in range(0,NoMoves,1):
value=rd.randint(0,5)
if value==0: c='F'
elif value==1: c='B'
elif value==2: c='U'
elif value==3: c='D'
elif value==4: c='R'
elif value==5: c='L'
else: c='E'
up=rd.randint(0,1)
if up==0: c+='_'
string+=c
print('the moves are: '+string)
return string
## Aquí
print('generando secuencia')
cadena=generador()
mov=movesGenerator(20)
a = ComArd.ArduinoCom("COM4",9600)
sleep(2)
print('Enviando cadena')
#a.write(cadena)
sleep(5)
print('Enviando movimientos')
#a.write(mov)
op=input('''
* Introduce la secuencia *
* o ^
* un carácter
* x para salir *
''')
while op!='x' and op!='\t':
a.write(op)
if op.upper()=='RECIBIR':
sleep(1)
print(a.read())
else:
a.write(op)
op=input("Escriba siguiente secuencia: ")
a.Close()