You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/programming_guide/02_analog_io.rst
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -488,5 +488,11 @@ Try using a loop to go through all 0-100% duty cycle values and back:
488
488
You should see the LED fade from off to fully on and back down to off
489
489
repeatedly. Press Ctrl-C to stop the loop and get back to the serial REPL.
490
490
491
+
And remember you can make a handy Python function to more easily set PWM duty cycle. For example given a value from 0.0 to 1.0 (0 to 100%) it can compute the necessary duty cycle value for you:
492
+
493
+
>>> defduty_cycle_value(percent):
494
+
... returnint(percent *65535)
495
+
>>> led.duty_cycle = duty_cycle_value(0.5) # Set 50% duty cycle.
0 commit comments