from gpiozero import PWMOutputDevice
from time import sleep

# Define the GPIO pin (change this to the appropriate pin for your setup)
pwm_pin = 18

# Create a PWM output object
pwm = PWMOutputDevice(pin=pwm_pin)

try:
    while True:
        # Ramp up the PWM duty cycle from 0 to 1 in steps of 0.1
        for duty_cycle in range(0, 11):
            pwm.value = duty_cycle / 70.0
            sleep(0.05)

        # Ramp down the PWM duty cycle from 1 to 0 in steps of 0.1
        for duty_cycle in range(10, -1, -1):
            pwm.value = duty_cycle / 70.0
            sleep(0.05)

except KeyboardInterrupt:
    # Clean up when the program is interrupted
    pwm.close()
