0
from machine import Pin, PWM
from time import sleep

pwm = PWM(Pin(15))

pwm.freq(1000)

while True:
    for duty in range(65025):
        pwm.duty_u16(duty)
        sleep(0.0001)
    for duty in range(65025, 0, -1):
        pwm.duty_u16(duty)
        sleep(0.0001)
Jonas
  • 121,568
  • 97
  • 310
  • 388

1 Answers1

0

If the code you've posted here is exactly what you are trying to run on your MicroPython board then the problem is that you've used a mixture of spaces and tab characters to indent different lines. You need to stick to either one or the other - the standard for Python is to use four spaces for each level of indentation.

Check the settings of whatever program you are using to edit your code to see if you can change what happens when you press the tab key. If you're copying and pasting code from a web page or elsewhere, you need to check how it's indented and make it consistent with your own code and editor.

nekomatic
  • 5,988
  • 1
  • 20
  • 27