Skip to content

Instantly share code, notes, and snippets.

@pranav6670
Created July 27, 2020 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pranav6670/7ef08ae59f3c883e49114d16da89570b to your computer and use it in GitHub Desktop.
Save pranav6670/7ef08ae59f3c883e49114d16da89570b to your computer and use it in GitHub Desktop.
Detect arduino connected to any of ports.
import serial.tools.list_ports
ports = list(serial.tools.list_ports.comports())
Arduino_ports = []
for p in ports:
if 'Arduino' in p.description:
Arduino_ports.append(p)
print("Board detected at")
if len(Arduino_ports) == 0:
print("no Arduino board detected")
print(Arduino_ports[0].device)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment