Generate PWM signal with specified duty cycle on digital pin
Specify a 0.33 duty cycle for an LED attached to digital pin 5 on Arduino hardware.
a = arduino(); writePWMDutyCycle(a,'D5',0.33);
a— Arduino hardware connection
Arduino hardware connection
arduino, specified as an object.
pin— Digital pin number
Digital pin number on the physical hardware, specified as a character vector.
dutyCycle— Value of the digital pin duty cycle
Value of digital pin’s PWM duty cycle specified as number
writePWMDutyCycle 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
writePWMDutyCycle in the MATLAB Function