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.


Generate PWM signal with specified duty cycle on digital pin


writePWMDutyCycle(a, pin, dutyCycle)



writePWMDutyCycle(a, pin, dutyCycle) sets the PWM duty cycle on a digital pin specified for the Arduino® hardware a.


collapse all

Specify a 0.33 duty cycle for an LED attached to digital pin 5 on Arduino hardware.

a = arduino();

Input Arguments

collapse all

Arduino hardware connection created using arduino, specified as an object.

Digital pin number on the physical hardware, specified as a character vector.

Value of digital pin’s PWM duty cycle specified as number between 0 and 1.

Introduced in R2014b