https://github.com/codeadamca/spike-speaker
A basic example of using MicroPython and the speaker on the LEGO Spike hub.
https://github.com/codeadamca/spike-speaker
lego mindstorms python spike
Last synced: 6 months ago
JSON representation
A basic example of using MicroPython and the speaker on the LEGO Spike hub.
- Host: GitHub
- URL: https://github.com/codeadamca/spike-speaker
- Owner: codeadamca
- Created: 2022-07-10T18:47:16.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-26T22:26:23.000Z (8 months ago)
- Last Synced: 2025-01-26T23:21:28.082Z (8 months ago)
- Topics: lego, mindstorms, python, spike
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LEGO® Spike Hub and the Speaker
A Python snippet utilizing the LEGO Spike speaker, [MicroPython](https://lego.github.io/MINDSTORMS-Robot-Inventor-hub-API/), and the `beep()`, `start_beep()`, `stop()`, `play_sound()`, and `set_volume()` commands.
## Sample Code
```py
from mindstorms import MSHub
from mindstorms.control import wait_for_secondshub = MSHub()
hub.speaker.beep()
hub.speaker.beep(44, 2, 50)
hub.speaker.beep(123, 4, 100)hub.speaker.start_beep(60, 100)
wait_for_seconds(2)
hub.speaker.stop()hub.speaker.play_sound('Celebrate', 50)
hub.speaker.start_sound('Shut Down')
wait_for_seconds(2)hub.speaker.beep()
```***
## Repo Resources
* [Visual Studio Code](https://code.visualstudio.com/)
* [MicroPython for LEGO Robot Inventor](https://www.lego.com/en-ca/themes/mindstorms/downloads)
* [LEGO Mindstorms](https://www.lego.com/en-ca/themes/mindstorms)
* [LEGO Mindstorms App for Mac](https://apps.apple.com/us/app/lego-mindstorms-inventor/id1515448947)
* [LEGO Mindstorms App for Android](https://play.google.com/store/apps/details?id=com.lego.retail.mindstorms)
* [LEGO Mindstorms App for Windows](https://www.microsoft.com/store/apps/9N7GN3KC2GK6)