Skip to content

Commit 6a3d823

Browse files
fixed port finding
1 parent fe012ac commit 6a3d823

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__*

electroblocks.zip

-1.3 KB
Binary file not shown.

electroblocks/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def __init__(self, baudrate=115200, timeout=2):
1010
def _auto_connect(self, baudrate, timeout):
1111
ports = list(serial.tools.list_ports.comports())
1212
for p in ports:
13-
if "Arduino" in p.description or "ttyACM" in p.device or "ttyUSB" in p.device:
13+
if p.vid == 9025 and p.pid == (67, 16): # Arduino Uno or Mega
1414
try:
1515
ser = serial.Serial(p.device, baudrate, timeout=timeout)
1616
time.sleep(2) # Give Arduino time to reset

servos.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from electroblocks import ElectroBlocks
2+
import time
3+
eb = ElectroBlocks()
4+
eb.config_servo(6)
5+
6+
while True:
7+
# Move servo to 0 degrees
8+
eb.set_servo(6, 0)
9+
# Wait for 1 second
10+
time.sleep(1)
11+
# Move servo to 90 degrees
12+
eb.set_servo(6, 90)
13+
# Wait for 1 second
14+
time.sleep(1)
15+
# Move servo to 180 degrees
16+
eb.set_servo(6, 180)
17+
# Wait for 1 second
18+
time.sleep(1)

0 commit comments

Comments
 (0)