# mPy - FKS0001 PWM excercises, servo range
# Copyright by Athony Vogelaar, Perth Scotland
# rev 0.10  2025-12-21  initial release

from 	machine	import	Pin, PWM, freq;		freq(240_000_000)
import	time

# ======================== main =============================

# Frequency range PWM: 1Hz .. 40 MHz 
def main():
    servo = PWM(Pin(27), freq=50); servo.duty_ns(1_500_000)
    try:
        while True:
            for a in (1_000_000, 1_500_000, 2_000_000, 1_500_000):
                servo.duty_ns(a)
                time.sleep(1)
    except:
        pass
    finally:
        servo.duty_ns(1_500_000)
        time.sleep(1)
        servo.deinit()


main()

# ======================== end =============================
