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 voltage on digital pin


writePWMVoltage(a, pin, voltage)



writePWMVoltage(a, pin, voltage) writes the specified voltage value to the PWM pin on the Arduino® hardware.


collapse all

Specify digital pin 5 on Arduino hardware to have 3 volts.

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.

Voltage of digital pin’s PWM specified as number between 0 and 5 volts. Check your hardware data sheet for accepted voltage ranges. For example, Arduino Uno accepts 0 – 5 V and Arduino Due accepts 0 – 3.3 V.

Introduced in R2014b