Difference between revisions of "Component: PWM (Internal) (General Output)"
From Flowcode Help
Jump to navigationJump to searchLine 14: | Line 14: | ||
==PWM (Internal) component== | ==PWM (Internal) component== | ||
Pulse Width Modulation, a versitile way of generating a digital pulse using mark / space modulation. Uses the capture compare peripherals onboard most Microcontrollers to generate accurate waveforms without any intervention from the processor. Useful for generating audio, controlling the speed of motors, brightness of LED etc. | Pulse Width Modulation, a versitile way of generating a digital pulse using mark / space modulation. Uses the capture compare peripherals onboard most Microcontrollers to generate accurate waveforms without any intervention from the processor. Useful for generating audio, controlling the speed of motors, brightness of LED etc. | ||
+ | |||
+ | ==Component Pack== | ||
+ | |||
+ | BASICIO | ||
==Detailed description== | ==Detailed description== | ||
+ | |||
+ | |||
Line 30: | Line 36: | ||
==Examples== | ==Examples== | ||
+ | |||
+ | |||
Revision as of 16:31, 7 January 2022
Author | Matrix Ltd |
Version | 2.1 |
Category | General Output |
Contents
PWM (Internal) component
Pulse Width Modulation, a versitile way of generating a digital pulse using mark / space modulation. Uses the capture compare peripherals onboard most Microcontrollers to generate accurate waveforms without any intervention from the processor. Useful for generating audio, controlling the speed of motors, brightness of LED etc.
Component Pack
BASICIO
Detailed description
No detailed description exists yet for this component
Examples
Here is a basic example to control the PWM duty based on an ADC reading.
Digital PWM trace
Here is another basic example which ramps the PWM duty cycle up and down. If the PWM output pin is connected to a LED and series resistor then the LED will smoothly transition between on bright and off.
Downloadable macro reference
![]() |
Disable |
Disables a PWM channel and allows the default output / input state to be resumed | |
![]() |
Return |
![]() |
Enable |
Enables a PWM channel as an output overriding the default output pin state. | |
![]() |
Return |
![]() |
SetFrequency |
Sets a PWM of the specifed frequency at a duty of 50% Ideal use is a frequency generator | |
![]() |
Frequency |
Enter frequency in Hz | |
![]() |
Return |