| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
PWM Library Example

The PWM Library Example demonstrates the use of the pulse-width modulation library by generating waveforms over a GPIO. The GPIO pin could drive a small speaker, for example.

This example generates two variable duty cycle pulses using two PWM channels (with positive and negative polarity). The duty cycle is changed automatically and will vary between 0 and 100.

The application uses the duty cycle pulses to drive LED 1 and LED 2. With a higher value, the light intensity of one of the LEDs increases, while the intensity of the other LED decreases.

# Setup

You can find the source code and the project file of the example in the following folder: `<InstallFolder>\examples\peripheral\pwm_library`

LED assignments:

- LED 1 shows the duty cycle of channel 1.
- LED 2 shows the duty cycle of channel 2 (negative polarity).

# Testing

Test the PWM Library Example application by performing the following steps:

1. Compile and program the application.
2. Observe that the LED light intensity changes. LED 1 should give the opposite light intensity compared to LED 2.