https://github.com/codeadamca/spike-motors
A basic example of using the LEGO Spike motor function.
https://github.com/codeadamca/spike-motors
lego mindstorms python
Last synced: 3 months ago
JSON representation
A basic example of using the LEGO Spike motor function.
- Host: GitHub
- URL: https://github.com/codeadamca/spike-motors
- Owner: codeadamca
- Created: 2022-07-06T17:13:15.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-07T18:09:13.000Z (almost 2 years ago)
- Last Synced: 2023-08-07T20:04:05.677Z (almost 2 years ago)
- Topics: lego, mindstorms, python
- Homepage:
- Size: 11.7 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 Motors
A Python snippet utilizing the LEGO Spike motors, [MicroPython](https://lego.github.io/MINDSTORMS-Robot-Inventor-hub-API/), and a variety of commands: `start()`, `stop()`, `run_for_seconds()`, and `run_for_rotations()`.
## Sample Code
```py
from mindstorms import MSHub, Motor, MotorPair
from mindstorms.control import wait_for_seconds
import mathhub = MSHub()
motor_a = Motor('A')
motor_b = Motor('B')motor_a.run_for_rotations(1, 100)
motor_b.run_for_rotations(1, 10)
motor_a.run_for_seconds(2, 100)
motor_b.run_for_seconds(2, -10)
motor_a.start(100)
motor_b.start(100)wait_for_seconds(2)
hub.light_matrix.write(motor_a.get_speed())
motor_a.stop()
motor_b.stop()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)