主要内容

PWM and Servo Control

Control pulse width modulated signals and servo motors on Raspberry Pi® hardware

Configure blocks and MATLAB® objects to generate PWM signals and control standard servo motors on Raspberry Pi hardware. Set PWM output for devices like LEDs, motors, and actuators, or precisely position servo motors using pan tilt hat for interactive application-based examples.

Blocks

PWMGenerate pulse width modulated signal of digital output pin
Pan Tilt HatControl pan and tilt motions using PCA9685-based PWM driver (Since R2022a)
Standard Servo WriteSet shaft position of standard servo motor to angle specified in degrees

Objects

servoCreate connection to servo motor

Functions

writePWMFrequencyWrites PWM frequency to a GPIO pin
writePWMVoltageWrites average PWM voltage to a GPIO pin
writePWMDutyCycleWrites PWM duty cycle to PWM pin
writePositionWrite position of servo motor

Topics

Featured Examples