official skill

Pan & scan

pan_scan.py

Sweep the pan motor back and forth to cover a field of view.

mountedvision
Author
MyRoboBrick
Build
Sentry
Language
MicroPython · SPIKE Prime
pan_scan.py
1from spike import Motor2import time3 4head = Motor("A")5 6def sweep(center=180, span=120, step=15, dwell=0.5):7    low = center - span // 28    high = center + span // 29    pos = low10    direction = 111    while True:12        pos += step * direction13        if pos >= high or pos <= low:14            direction *= -115        # run_to_position expects an absolute target in 0-359 degrees.16        head.run_to_position(pos % 360)17        time.sleep(dwell)18 19sweep()

Read every line before running it on real hardware.

Have a skill worth sharing?

Submit your own MicroPython skill. Everything is reviewed for safety before it shows up for other builders.