Update D13 to LED, add PWM example.
This commit is contained in:
parent
a8b69f2852
commit
a63af1d04a
@ -99,7 +99,7 @@ For example, a user can then use ``deinit()```::
|
|||||||
import board
|
import board
|
||||||
import time
|
import time
|
||||||
|
|
||||||
led = digitalio.DigitalInOut(board.D13)
|
led = digitalio.DigitalInOut(board.LED)
|
||||||
led.direction = digitalio.Direction.OUTPUT
|
led.direction = digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
@ -119,7 +119,7 @@ Alternatively, using a ``with`` statement ensures that the hardware is deinitial
|
|||||||
import board
|
import board
|
||||||
import time
|
import time
|
||||||
|
|
||||||
with digitalio.DigitalInOut(board.D13) as led:
|
with digitalio.DigitalInOut(board.LED) as led:
|
||||||
led.direction = digitalio.Direction.OUTPUT
|
led.direction = digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
|
@ -50,9 +50,9 @@
|
|||||||
//| For example::
|
//| For example::
|
||||||
//|
|
//|
|
||||||
//| import digitalio
|
//| import digitalio
|
||||||
//| from board import *
|
//| import board
|
||||||
//|
|
//|
|
||||||
//| pin = digitalio.DigitalInOut(D13)
|
//| pin = digitalio.DigitalInOut(board.LED)
|
||||||
//| print(pin.value)
|
//| print(pin.value)
|
||||||
//|
|
//|
|
||||||
//| This example will initialize the the device, read
|
//| This example will initialize the the device, read
|
||||||
@ -61,11 +61,11 @@
|
|||||||
//|
|
//|
|
||||||
//| Here is blinky::
|
//| Here is blinky::
|
||||||
//|
|
//|
|
||||||
//| import digitalio
|
|
||||||
//| from board import *
|
|
||||||
//| import time
|
//| import time
|
||||||
|
//| import digitalio
|
||||||
|
//| import board
|
||||||
//|
|
//|
|
||||||
//| led = digitalio.DigitalInOut(D13)
|
//| led = digitalio.DigitalInOut(board.LED)
|
||||||
//| led.direction = digitalio.Direction.OUTPUT
|
//| led.direction = digitalio.Direction.OUTPUT
|
||||||
//| while True:
|
//| while True:
|
||||||
//| led.value = True
|
//| led.value = True
|
||||||
|
@ -46,11 +46,11 @@
|
|||||||
//|
|
//|
|
||||||
//| For example::
|
//| For example::
|
||||||
//|
|
//|
|
||||||
//| import frequencyio
|
|
||||||
//| import time
|
//| import time
|
||||||
//| from board import *
|
//| import frequencyio
|
||||||
|
//| import board
|
||||||
//|
|
//|
|
||||||
//| frequency = frequencyio.FrequencyIn(D13)
|
//| frequency = frequencyio.FrequencyIn(board.D11)
|
||||||
//| frequency.capture_period = 15
|
//| frequency.capture_period = 15
|
||||||
//| time.sleep(0.1)
|
//| time.sleep(0.1)
|
||||||
//|
|
//|
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
//| import board
|
//| import board
|
||||||
//|
|
//|
|
||||||
//| # 50% duty cycle at 38kHz.
|
//| # 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
|
//| # on off on off on
|
||||||
//| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000])
|
//| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000])
|
||||||
//| pulse.send(pulses)
|
//| pulse.send(pulses)
|
||||||
|
@ -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 int frequency: The target frequency in Hertz (32-bit)
|
||||||
//| :param bool variable_frequency: True if the frequency will change over time
|
//| :param bool variable_frequency: True if the frequency will change over time
|
||||||
//|
|
//|
|
||||||
//| Simple LED fade::
|
//|
|
||||||
|
//| Simple LED on::
|
||||||
//|
|
//|
|
||||||
//| import pwmio
|
//| import pwmio
|
||||||
//| import board
|
//| import board
|
||||||
//|
|
//|
|
||||||
//| pwm = pwmio.PWMOut(board.D13) # output on D13
|
//| pwm = pwmio.PWMOut(board.LED)
|
||||||
//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz
|
//|
|
||||||
|
//| 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)::
|
//| PWM at specific frequency (servos and motors)::
|
||||||
//|
|
//|
|
||||||
@ -100,7 +116,7 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) {
|
|||||||
//| import board
|
//| import board
|
||||||
//|
|
//|
|
||||||
//| pwm = pwmio.PWMOut(board.D13, frequency=50)
|
//| 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)::
|
//| Variable frequency (usually tones)::
|
||||||
//|
|
//|
|
||||||
|
@ -45,11 +45,11 @@
|
|||||||
//|
|
//|
|
||||||
//| For example::
|
//| For example::
|
||||||
//|
|
//|
|
||||||
//| import pwmio
|
|
||||||
//| import time
|
//| import time
|
||||||
//| from board import *
|
//| import pwmio
|
||||||
|
//| import board
|
||||||
//|
|
//|
|
||||||
//| pwm = pwmio.PWMOut(D13)
|
//| pwm = pwmio.PWMOut(board.LED)
|
||||||
//| pwm.duty_cycle = 2 ** 15
|
//| pwm.duty_cycle = 2 ** 15
|
||||||
//| time.sleep(0.1)
|
//| time.sleep(0.1)
|
||||||
//|
|
//|
|
||||||
|
@ -3,7 +3,6 @@ import audiopwmio
|
|||||||
import board
|
import board
|
||||||
import digitalio
|
import digitalio
|
||||||
import time
|
import time
|
||||||
import math
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
trigger = digitalio.DigitalInOut(board.D4)
|
trigger = digitalio.DigitalInOut(board.D4)
|
||||||
|
@ -3,7 +3,6 @@ import audiopwmio
|
|||||||
import board
|
import board
|
||||||
import digitalio
|
import digitalio
|
||||||
import time
|
import time
|
||||||
import math
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
trigger = digitalio.DigitalInOut(board.D4)
|
trigger = digitalio.DigitalInOut(board.D4)
|
||||||
|
Loading…
Reference in New Issue
Block a user