2. Start a Python project and paste the whole library at the top
Open the LEGO SPIKE App → New project → choose "Python" (not Word Blocks). A SPIKE App project cannot hold extra files, so paste the whole content of MBC_servo6_SPIKE_App_Lib.py at the top of the program. Then write your code below it:
from hub import port
import time
# ↑ paste the whole MBC_servo6_SPIKE_App_Lib.py above this line
sv = MBC_SERVO6(port.C) # expander on hub Port C
sv.servo_angle(1, 90) # servo 1 to 90 degrees
time.sleep_ms(1000)
sv.servo_angle(1, 0, 10) # turn slowly to 0 degrees, 60 degrees per second
sv.servo_wait(1) # wait until it gets there
print("Servo 1 current mA:", sv.get_current(1))
sv.stop_all() # release all at the end
Want to use blocks?
For now, the Servo6 can only be programmed with Pybricks blocks (the hub needs Pybricks firmware v4.0 or later, and block coding needs a Pybricks licence), or by writing Pybricks (MicroPython). The MBC Blocks website does not have Servo6 blocks yet.
The Servo6 is still being tested before release. The SPIKE App library has not yet been tried on every version of the app and hub. If something goes wrong, please tell us.