That looks like MicroPython code that you’re trying to run there - try this CircuitPython code! It uses the pwmio library, but I think that should come built into to your CircuitPython image.
That looks like MicroPython code that you’re trying to run there - try this CircuitPython code! It uses the pwmio library, but I think that should come built into to your CircuitPython image.