Simple test

Ensure your device works with this simple test.

examples/sc_servo_simpletest.py
 1# SPDX-FileCopyrightText: Copyright (c) 2025 Jacques Supcik
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import time
 6
 7import board
 8
 9from sc_servo import SerialControlledServo
10
11POSITIONS = [0, 307, 614, 307]
12SPEED = 1000
13
14
15def main() -> None:
16    # Replace boards.IO02 and board.IO01 with the appropriate pins for your board
17    servo = SerialControlledServo(tx_pin=board.IO02, rx_pin=board.IO01)
18    index: int = 0
19    while True:
20        servo.set_position(servo_id=1, pos=POSITIONS[index], speed=SPEED)
21        index = (index + 1) % len(POSITIONS)
22        while servo.is_moving(servo_id=1):
23            time.sleep(0.1)
24        time.sleep(0.5)  # Wait 1/2 second
25
26
27main()