This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

writePWMDutyCycle

Set PWM duty cycle on BBC micro:bit board pin

Syntax

writePWMDutyCycle(microbitObj,pin,dutyCycle)

Description

example

writePWMDutyCycle(microbitObj,pin,dutyCycle) sets the specified duty cycle value to a pin configured for PWM on the BBC micro:bit board, specified as a microbit object.

Examples

collapse all

Specify a PWM duty cycle of 0.2 for pin P7 on the BBC micro:bit board.

microbitObj = microbit('COM3');
writePWMDutyCycle(microbitObj,'P7',0.2)

Input Arguments

collapse all

BBC micro:bit hardware connection, specified as a microbit object created with the microbit function.

Pin number that supports PWM on the BBC micro:bit board, specified as a character vector.

Example: 'P7'

Value of the PWM duty cycle, specified as a real number ranging from 0 to 1.

Data Types: double

Introduced in R2017b