PulseOut is used to pulse PWM “carrier” output on and off. This is commonly used in infrared remotes. The pulsed signal consists of timed on and off periods. Unlike PWM, there is no set duration for on and off pairs.
Create a PulseOut object associated with the given PWMout object.
Parameters: carrier (PWMOut) – PWMOut that is set to output on the desired pin.
Send a short series of pulses:
import array import pulseio import board # 50% duty cycle at 38kHz. pwm = pulseio.PWMOut(board.D13, frequency=38000, duty_cycle=32768) pulse = pulseio.PulseOut(pwm) # on off on off on pulses = array.array('H', [65000, 1000, 65000, 65000, 1000]) pulse.send(pulses) # Modify the array of pulses. pulses = 200 pulse.send(pulses)
Deinitialises the PulseOut and releases any hardware resources for reuse.
No-op used by Context Managers.
Automatically deinitializes the hardware when exiting a context. See Lifetime and ContextManagers for more info.
Pulse alternating on and off durations in microseconds starting with on.
pulsesmust be an
array.arraywith data type ‘H’ for unsigned halfword (two bytes).
This method waits until the whole array of pulses has been sent and ensures the signal is off afterwards.
Parameters: pulses (array.array) – pulse durations in microseconds