Build HAT
The Python Build HAT library supports the Raspberry Pi Build HAT, an add-on board for the Raspberry Pi computer, which allows control of up to four LEGO® TECHNIC™ motors and sensors included in the SPIKE™ Portfolio.
Hardware
The Build HAT provides four connectors for LEGO® Technic™ motors and sensors from the SPIKE™ Portfolio. The available sensors include a distance sensor, a colour sensor, and a versatile force sensor. The angular motors come in a range of sizes and include integrated encoders that can be queried to find their position.
The Build HAT fits all Raspberry Pi computers with a 40-pin GPIO header, including — with the addition of a ribbon cable or other extension device — Raspberry Pi 400. Connected LEGO® Technic™ devices can easily be controlled in Python, alongside standard Raspberry Pi accessories such as a camera module.
Documentation
Library documentation: https://buildhat.readthedocs.io
Hardware documentation: https://www.raspberrypi.com/documentation/accessories/build-hat.html
Projects and inspiration: https://projects.raspberrypi.org/en/pathways/lego-intro
Installation
To install the Build HAT library, enter the following commands in a terminal:
pip3 install buildhat
Usage
See the detailed documentation for the Python objects available.
import time
from signal import pause
from buildhat import Motor
motor = Motor('A')
motor.set_default_speed(30)
print("Position", motor.get_aposition())
def handle_motor(speed, pos, apos):
print("Motor", speed, pos, apos)
motor.when_rotated = handle_motor
print("Run for degrees")
motor.run_for_degrees(360)
print("Run for seconds")
motor.run_for_seconds(5)
print("Run for rotations")
motor.run_for_rotations(2)
print("Start motor")
motor.start()
time.sleep(3)
print("Stop motor")
motor.stop()
pause()
Building locally
Using asdf:
asdf install
Then:
pip3 install . --user
Building the documentation
Instructions for regenerating the documentation can be found in
docs/README.md. Briefly, assuming you have the appropriate python
modules installed:
$ (cd docs; make html)
will rebuild the documentation. The doc tree starts at docs/build/html/index.html
Metadata
Release files for buildhat 0.5.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| buildhat-0.5.10.tar.gz | 155.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| buildhat-0.5.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 212.6 kB
Release files / buildhat-0.5.10.tar.gz
| Download URL | buildhat-0.5.10.tar.gz |
|---|---|
| Size | 155.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9100df134485d1c6d0582ba11ac729fdd8c497409bcf50a71402c2692fc4644c
|
|
BLAKE2b-256 checksum How to use checksums |
642b535dcb8b567c8363bf3a413591560c363275c584ab769c11ae6948fca2d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.2
|
Release files / buildhat-0.5.10-py3-none-any.whl
| Download URL | buildhat-0.5.10-py3-none-any.whl |
|---|---|
| Size | 56.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32fc1e01cec92caf42b964a26d171415b41d8ee01e5bd61084d87a0793f0a7f9
|
|
BLAKE2b-256 checksum How to use checksums |
012323511c4ce88d022ecad252f1bb062b3ed1afcfa223a8591609230d4afb0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.2
|
Security for buildhat 0.5.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.