Merge pull request #5523 from kattni/led-docs-update

Update D13 to LED, add PWM example.
This commit is contained in:
Dan Halbert 2021-10-28 15:11:28 -04:00 committed by GitHub
commit fd85ebf88a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 20 deletions

View File

@ -99,7 +99,7 @@ For example, a user can then use ``deinit()```::
import board
import time
led = digitalio.DigitalInOut(board.D13)
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
for i in range(10):
@ -119,7 +119,7 @@ Alternatively, using a ``with`` statement ensures that the hardware is deinitial
import board
import time
with digitalio.DigitalInOut(board.D13) as led:
with digitalio.DigitalInOut(board.LED) as led:
led.direction = digitalio.Direction.OUTPUT
for i in range(10):

View File

@ -50,9 +50,9 @@
//| For example::
//|
//| import digitalio
//| from board import *
//| import board
//|
//| pin = digitalio.DigitalInOut(D13)
//| pin = digitalio.DigitalInOut(board.LED)
//| print(pin.value)
//|
//| This example will initialize the the device, read
@ -61,11 +61,11 @@
//|
//| Here is blinky::
//|
//| import digitalio
//| from board import *
//| import time
//| import digitalio
//| import board
//|
//| led = digitalio.DigitalInOut(D13)
//| led = digitalio.DigitalInOut(board.LED)
//| led.direction = digitalio.Direction.OUTPUT
//| while True:
//| led.value = True

View File

@ -46,11 +46,11 @@
//|
//| For example::
//|
//| import frequencyio
//| import time
//| from board import *
//| import frequencyio
//| import board
//|
//| frequency = frequencyio.FrequencyIn(D13)
//| frequency = frequencyio.FrequencyIn(board.D11)
//| frequency.capture_period = 15
//| time.sleep(0.1)
//|

View File

@ -59,7 +59,7 @@
//| import board
//|
//| # 50% duty cycle at 38kHz.
//| pwm = pulseio.PulseOut(board.D13, frequency=38000, duty_cycle=32768)
//| pwm = pulseio.PulseOut(board.LED, frequency=38000, duty_cycle=32768)
//| # on off on off on
//| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000])
//| pulse.send(pulses)

View File

@ -86,13 +86,29 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) {
//| :param int frequency: The target frequency in Hertz (32-bit)
//| :param bool variable_frequency: True if the frequency will change over time
//|
//| Simple LED fade::
//|
//| Simple LED on::
//|
//| import pwmio
//| import board
//|
//| pwm = pwmio.PWMOut(board.D13) # output on D13
//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz
//| pwm = pwmio.PWMOut(board.LED)
//|
//| while True:
//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz
//|
//| PWM LED fade::
//|
//| import pwmio
//| import board
//|
//| pwm = pwmio.PWMOut(board.LED) # output on LED pin with default of 500Hz
//|
//| while True:
//| for cycle in range(0, 65535): # Cycles through the full PWM range from 0 to 65535
//| pwm.duty_cycle = cycle # Cycles the LED pin duty cycle through the range of values
//| for cycle in range(65534, 0, -1): # Cycles through the PWM range backwards from 65534 to 0
//| pwm.duty_cycle = cycle # Cycles the LED pin duty cycle through the range of values
//|
//| PWM at specific frequency (servos and motors)::
//|
@ -100,7 +116,7 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) {
//| import board
//|
//| pwm = pwmio.PWMOut(board.D13, frequency=50)
//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at 50hz
//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at 50hz
//|
//| Variable frequency (usually tones)::
//|

View File

@ -45,11 +45,11 @@
//|
//| For example::
//|
//| import pwmio
//| import time
//| from board import *
//| import pwmio
//| import board
//|
//| pwm = pwmio.PWMOut(D13)
//| pwm = pwmio.PWMOut(board.LED)
//| pwm.duty_cycle = 2 ** 15
//| time.sleep(0.1)
//|

View File

@ -3,7 +3,6 @@ import audiopwmio
import board
import digitalio
import time
import math
import os
trigger = digitalio.DigitalInOut(board.D4)

View File

@ -3,7 +3,6 @@ import audiopwmio
import board
import digitalio
import time
import math
import os
trigger = digitalio.DigitalInOut(board.D4)