Skip to content

Commit 52bf3a8

Browse files
fixed serial and uplaoding new code
1 parent 6a3d823 commit 52bf3a8

File tree

6 files changed

+65
-5
lines changed

6 files changed

+65
-5
lines changed

.gitignore

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
__pycache__*
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# Virtual environment
7+
venv/
8+
.env/
9+
.venv/
10+
11+
# Distribution / packaging
12+
build/
13+
dist/
14+
*.egg-info/
15+
16+
# VS Code settings
17+
.vscode/
18+
19+
# Mac system files
20+
.DS_Store
21+
22+
# PyInstaller
23+
*.spec

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 p.vid == 9025 and p.pid == (67, 16): # Arduino Uno or Mega
13+
if p.vid == 9025 and p.pid in (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

pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "electroblocks"
7+
version = "0.1.0"
8+
description = "Python client library to interact with ElectroBlocks Arduino firmware"
9+
authors = [
10+
{ name = "Noah Glaser", email = "[email protected]" }
11+
]
12+
license = { text = "MIT" }
13+
readme = "README.md"
14+
requires-python = ">=3.6"
15+
dependencies = [
16+
"pyserial"
17+
]
18+
19+
[project.urls]
20+
Homepage = "https://github.com/ElectroBlocks/python"

requirements.txt

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

servos.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
while True:
77
# Move servo to 0 degrees
8-
eb.set_servo(6, 0)
8+
eb.move_servo(6, 0)
99
# Wait for 1 second
1010
time.sleep(1)
1111
# Move servo to 90 degrees
12-
eb.set_servo(6, 90)
12+
eb.move_servo(6, 90)
1313
# Wait for 1 second
1414
time.sleep(1)
1515
# Move servo to 180 degrees
16-
eb.set_servo(6, 180)
16+
eb.move_servo(6, 180)
1717
# Wait for 1 second
1818
time.sleep(1)

setup.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
# Setup script for ElectroBlocks Python development environment
3+
4+
echo "Creating virtual environment..."
5+
python3 -m venv venv
6+
7+
echo "Activating virtual environment..."
8+
source venv/bin/activate
9+
10+
echo "Installing dependencies..."
11+
pip install -r requirements.txt
12+
13+
echo "Installing ElectroBlocks in editable mode..."
14+
pip install -e .
15+
16+
echo "Setup complete. To activate later, run:"
17+
echo "source venv/bin/activate"

0 commit comments

Comments
 (0)