Update D13 to LED, add PWM example.

This commit is contained in:
Kattni Rembor 2021-10-28 13:30:51 -04:00
parent a8b69f2852
commit a63af1d04a
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,14 +86,30 @@ 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 = 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)::
//|
//| import pwmio

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)