Main Content

writePWMVoltage

Generate PWM signal with specified voltage on digital pin

Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.

Description

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

example

Examples

collapse all

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

a = arduino();
writePWMVoltage(a,'D5',3);

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 more information, see Supported Boards.

More About

collapse all

Code Generation Using MATLAB Function Block

  • Use writePWMVoltage in a MATLAB® Function block with the Simulink® Support Package for Arduino Hardware to generate code that can be deployed on Arduino Hardware.

  • Configure the Arduino peripherals to the appropriate mode using configurePin before using writePWMVoltage in the MATLAB Function block.

Version History

Introduced in R2014b