Skip to content

Commit 48e12da

Browse files
authored
Set dc motor power with CyberPi controller
Set dc motor power with CyberPi controller
1 parent eb7e787 commit 48e12da

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import cyberpi, mbot2
2+
from time import sleep
3+
4+
cyberpi.display.show_label("mBot2 DC Motor ",16,0,0,0)
5+
6+
mbot2.motor_set(0,"all")
7+
8+
while True:
9+
m1_power = mbot2.motor_get("M1")
10+
cyberpi.display.show_label("current Power\nM1:{}".format(m1_power),16,0,20,1)
11+
12+
if cyberpi.controller.is_press('up'):
13+
mbot2.motor_set(100,"all")
14+
15+
elif cyberpi.controller.is_press('down'):
16+
mbot2.motor_set(-100,"all")
17+
18+
elif cyberpi.controller.is_press('middle'):
19+
mbot2.motor_set(0,"all")

0 commit comments

Comments
 (0)