diff --git a/code/pybricks-test01/main.py b/code/pybricks-test01/main.py new file mode 100644 index 0000000..fdcf173 --- /dev/null +++ b/code/pybricks-test01/main.py @@ -0,0 +1,33 @@ +from pybricks.parameters import Color, Port +from pybricks.pupdevices import ColorDistanceSensor, Motor +from pybricks.tools import wait + +# Say hello :) +print("Hello, Pybricks!") + +motor = Motor(Port.A) +# dial = Motor(Port.A) +sensor = ColorDistanceSensor(Port.B) +# Sensor light will be set to Color.GREEN when measuring distance +sensor.light.off() + +# First, we'll move the dial to zero. +# dial.run_target(500, 0, Stop.COAST) + +while True: + # Set the speed based on sensor distance + dist = sensor.distance() + sensor.light.on(Color.RED) + speed = dist * 5 + if abs(speed) < 100: + speed = 0 + print("dist=", dist, ", speed=", speed) + # speed = dial.angle() * 3 + + # Run motor at desired speed + motor.run(speed) + + # Wait briefly, then repeat + wait(100) + +# EOF diff --git a/code/pybricks-test01/requirements.txt b/code/pybricks-test01/requirements.txt new file mode 100644 index 0000000..e6631ba --- /dev/null +++ b/code/pybricks-test01/requirements.txt @@ -0,0 +1 @@ +pybricks diff --git a/docs/bibliography.md b/docs/bibliography.md index 783e4fe..1dd2522 100644 --- a/docs/bibliography.md +++ b/docs/bibliography.md @@ -27,7 +27,7 @@ * [Powered Up - A tear down...](https://www.eurobricks.com/forum/index.php?/forums/topic/162288-powered-up-a-tear-down/) - Eurobricks Forum, 2018-06-07 * Reverse Engineering the LEGO BOOST Move Hub: * Python for LEGO BOOST: -* [Build and Code Creative Robots with LEGO BOOST](https://www.packtpub.com/product/build-and-code-creative-robots-with-lego-boost/9781801075572) by Ashwin Shah. Packt Publishing, November 2021 +* Book: [Build and Code Creative Robots with LEGO BOOST](https://www.packtpub.com/product/build-and-code-creative-robots-with-lego-boost/9781801075572) by Ashwin Shah. Packt Publishing, November 2021 * [Glossario by Italian LEGO® Users Group](https://itlug.org/glossario/) * [Smart Robotics with LEGO MINDSTORMS Robot Inventor](https://www.packtpub.com/product/smart-robotics-with-lego-mindstorms-robot-inventor/9781800568402) by Aaron Maurer. Packt Publishing, May 2021 @@ -37,6 +37,22 @@ * [LEGO Wireless Protocol 3.0.00](https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#document-index) * [Python library to interact with Move Hub / PoweredUp Hubs](https://github.com/undera/pylgbst) +New links to check and sort out: + +* Google Search: "[Powered Up Python library](https://www.google.com/search?q=Powered+Up+Python+library&oq=powered+up+Python+library)" +* Thread on StackExchange.com: [Which programming environments or APIs are available for the LEGO BOOST?](https://bricks.stackexchange.com/questions/10786/which-programming-environments-or-apis-are-available-for-the-lego-boost) +* [Hack Lego Boost with Raspberry Pi](https://magpi.raspberrypi.com/articles/hack-lego-boost-with-raspberry-pi) - The MagPi Magazine, 2019-xx-xx +* **pylgbst** - Python library to interact with Move Hub / PoweredUp Hubs + - GitHub repository: + - LibHunt: Pylgbst Alternatives: +* **BrickNil** - A Python async library for PoweredUp/Boost + - GitHub repository: + - Discussion on Eurobricks.com: +* +* +* +* + ## Python and Machine Learning * [Advanced Deep Learning with Python](https://www.packtpub.com/product/advanced-deep-learning-with-python/9781789956177) by Ivan Vasilev. Packt Publishing, December 2019 diff --git a/docs/howto/howto-control-rpi-poweredup.md b/docs/howto/howto-control-rpi-poweredup.md index 57a8a19..2170c7a 100644 --- a/docs/howto/howto-control-rpi-poweredup.md +++ b/docs/howto/howto-control-rpi-poweredup.md @@ -1,10 +1,49 @@ -# HOWTO Control a LEGO Powered Up Hub from a Raspberry Pi +# HOWTO Control a LEGO Powered Up Hub for the ARNEIS Project ## Introduction This document explains how to install a use a Python script to control a LEGO Powered Up Hub through BLE. -## Step-by-step instructions +## Using the "LEGO® TECHNIC™ CONTROL+" App + +Install the "LEGO® TECHNIC™ CONTROL+" app from + +* Google Play Store: +* Apple Store: TODO + +Launch the app and select set "Liebherr 9800". + +Connect 2x XL motor and 1x L motor to the Hub. + +Follow the instructions displayed by the app and update the firmware if requested. + +TODO + +## Using Pybricks + +### Install the Pybricks firmware + +Instructions at + +Before you begin, turn the hub off. The update works best with fresh batteries. +If you use the City Hub, you must unplug all motors and sensors. Follow these steps: + +1. Go to [Pybricks Code](https://code.pybricks.com/). +2. Press and hold the hub button. Wait for a blinking pink light. +3. While you hold it, click the _firmware update_ button. +4. Select the _LEGO Bootloader_ and click _Pair_. +5. Wait until the light turns off, and then blinks red/green/blue. +6. Release the button and wait for the installation to finish. + +### Load some Python program + +From the [Pybricks Code](https://code.pybricks.com/) web interface, create or open a MicroPython source file and upload it to the LEGO Technics BT Hub. You may find some examples under the `/code` folder of the [ARNEIS repository on GitHub](https://github.com/B-AROL-O/ARNEIS). + +TODO + +## Controlling from a Raspberrry Pi + +### Install undera/pylgbst on the Raspberry Pi