-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfindArduino.py
More file actions
45 lines (24 loc) · 923 Bytes
/
findArduino.py
File metadata and controls
45 lines (24 loc) · 923 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
36
37
38
39
40
41
42
43
44
45
# WaveShapePlay
# Find a detailed youtube tutorial for the Arduino Com Connection Code at: https://youtu.be/DJD28uK5qIk
import serial.tools.list_ports
def get_ports():
ports = serial.tools.list_ports.comports()
return ports
def findArduino(portsFound):
commPort = 'None'
numConnection = len(portsFound)
for i in range(0,numConnection):
port = foundPorts[i]
strPort = str(port)
if 'Arduino' in strPort:
splitPort = strPort.split(' ')
commPort = (splitPort[0])
return commPort
foundPorts = get_ports()
connectPort = findArduino(foundPorts)
if connectPort != 'None':
ser = serial.Serial(connectPort,baudrate = 9600, timeout=1)
print('Connected to ' + connectPort)
else:
print('Connection Issue!')
print('DONE')