/sw_pwm_nordic

Software Pulse-width modulation for LEDs on Nordic boards

Primary LanguageCBSD 4-Clause "Original" or "Old" LicenseBSD-4-Clause

Software Pulse-Width Modulation

This project was created during the Nordic Workshops 2023 in Kraków.

Tested on nRF52840DK

nRF52840DK

Note: if you want to use PWM and your board supports it, it will be much better to use hardware PWM.

Description

Pulse-Width Modulation is a method of controlling the average power delivered by an electrical signal. The average value of voltage (and current) fed to the load is controlled by switching the supply between 0 and 100% at a rate faster than it takes the load to change significantly.

After successful building you will be able to see smoothly blinking LEDs: LED1 and LED4:

blinking LEDs

You can also control the brightness of LED2 with BTN1 and BTN2. It can be turned off with BTN3 and turned on with BTN4.

Building

west build -b nrf52840dk_nrf52840
west flash

More about building you can find here.

You can also use nRF Connect for VSCode.