Skip to content

Commit b0d5700

Browse files
Update ex2_qwiic_scmd.py
Zero motors if they are running and change limits into proper range (0-254)
1 parent 89a255d commit b0d5700

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

examples/ex2_qwiic_scmd.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ def runExample():
6060
myMotor.begin()
6161
print("Motor initialized.")
6262
time.sleep(.250)
63+
64+
# Zero Motor Speeds
65+
myMotor.set_drive(0,0,0)
66+
myMotor.set_drive(1,0,0)
67+
6368
myMotor.enable()
6469
print("Motor enabled")
6570
time.sleep(.250)
@@ -72,7 +77,7 @@ def runExample():
7277
myMotor.set_drive(R_MTR,FWD,speed)
7378
myMotor.set_drive(L_MTR,BWD,speed)
7479
time.sleep(.05)
75-
for speed in range(255,20, -1):
80+
for speed in range(254,20, -1):
7681
print(speed)
7782
myMotor.set_drive(R_MTR,FWD,speed)
7883
myMotor.set_drive(L_MTR,BWD,speed)
@@ -84,4 +89,4 @@ def runExample():
8489
except (KeyboardInterrupt, SystemExit) as exErr:
8590
print("Ending example.")
8691
myMotor.disable()
87-
sys.exit(0)
92+
sys.exit(0)

0 commit comments

Comments
 (0)