Skip to content

Commit 11f63fb

Browse files
committed
docs: More analog IO updates.
1 parent 460b9f3 commit 11f63fb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/programming_guide/02_analog_io.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,5 +488,11 @@ Try using a loop to go through all 0-100% duty cycle values and back:
488488
You should see the LED fade from off to fully on and back down to off
489489
repeatedly. Press Ctrl-C to stop the loop and get back to the serial REPL.
490490

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+
>>> def duty_cycle_value(percent):
494+
... return int(percent * 65535)
495+
>>> led.duty_cycle = duty_cycle_value(0.5) # Set 50% duty cycle.
496+
491497
.. Author: Tony DiCola
492498
Copyright: 2017

0 commit comments

Comments
 (0)