This is an example program of WS2812 library https://developer.mbed.org/users/devararendy/code/WS2812/ in main program, i also put some line to measure how many asm NOP do we need. I have test it on STM32F411RE (Nucleo 411RE). if you would like to use another microcontroller, you need to adjust the asm("nop") in the library.

Dependencies:   USBDevice WS2812 mbed-os

Revision:
0:a27bf0451169
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Sat Dec 10 08:26:36 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#01321bd6ff89