Main Content

writePWMDutyCycle

Set PWM duty cycle on BBC micro:bit board pin

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

Version History

Introduced in R2017b