Hub to use instead of Boost, so that I can communicate with external devices #1247
Replies: 2 comments 2 replies
-
Since firmware version v3.3.0b8 there is
Yes.
Everything Powered Up is compatible with everything Powered Up. If the connector fits, it will work. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the pointer to comment #64. I had to tinker with it for a while, but I finally got it working, so leaving it here for the next person. If you see any possible ways to improve it please suggest them from pybricks.hubs import MoveHub
from pybricks.pupdevices import Motor, ColorDistanceSensor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch
from pybricks.tools import read_input_byte, run_task
hub = MoveHub()
async def read_line():
print('read_line()')
line = ''
while True:
b = read_input_byte()
# no input was available yet
if b is None:
# give other tasks a chance to run
await wait(0)
# then check for another byte
continue
# ignore carriage return
#if b == CR:
# continue
# line feed indicates end of line
if b == 13:
return line
line = line + chr(b)
async def red():
hub.light.on(Color.RED)
async def green():
hub.light.on(Color.GREEN)
async def main():
print('main()')
while True:
# wait for a command from the PC
command = await read_line()
print('command: ' + str(command))
if command == 'lr':
await red()
elif command == 'lg':
await green()
run_task(main()) |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm planning out my first project, which will communicate with an external device, and I just discovered that the Boost Move hub (of which I own 2, plus motors) doesn't support that (thanks for documenting that well). I plan on buying a different hub. Questions:
thanks
tom
Beta Was this translation helpful? Give feedback.
All reactions