-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ad90a9
commit 990fbd3
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import serial | ||
import time | ||
|
||
class Wheels: | ||
def __init__(self, port_num): | ||
self.arduino = serial.Serial(port=port_num, baudrate=115200, timeout=0.1) | ||
|
||
def write_read(self, x): | ||
self.arduino.write(bytes(x, 'utf-8')) | ||
time.sleep(0.05) | ||
|
||
def move(self, angle, dist): | ||
angle_str = str(angle).zfill(3) | ||
dist_str = str(dist).zfill(3) | ||
command = angle_str + dist_str | ||
self.write_read(command) | ||
|
||
if __name__ == "__main__": | ||
myFirstWheel = Wheels("your_port_number_here") | ||
myFirstWheel.move(angle_value, distance_value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import "./wheels.py" | ||
|
||
w = Wheels("COM4") | ||
w.move("100100") |