forked from Arcmyx/pynamics
Add templates/xboxcontroller.py
This commit is contained in:
18
templates/xboxcontroller.py
Normal file
18
templates/xboxcontroller.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from pybricks.pupdevices import Motor
|
||||||
|
from pybricks.parameters import Button, Direction, Port, Side, Stop
|
||||||
|
from pybricks.tools import run_task, multitask
|
||||||
|
from pybricks.tools import wait, StopWatch
|
||||||
|
from pybricks.robotics import DriveBase
|
||||||
|
from pybricks.iodevices import XboxController
|
||||||
|
from pybricks.hubs import PrimeHub
|
||||||
|
hub = PrimeHub()
|
||||||
|
testmotor = Motor(Port.C)
|
||||||
|
async def main():
|
||||||
|
while True:
|
||||||
|
if(Button.UP in buttons.pressed()):
|
||||||
|
testmotor.run(500)
|
||||||
|
else:
|
||||||
|
testmotor.stop()
|
||||||
|
await wait(10)
|
||||||
|
# Run the main function
|
||||||
|
run_task(main())
|
||||||
Reference in New Issue
Block a user