{"id":81128,"date":"2019-02-20T14:30:39","date_gmt":"2019-02-20T14:30:39","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=81128"},"modified":"2020-07-30T14:16:20","modified_gmt":"2020-07-30T14:16:20","slug":"micropython-ws2812b-addressable-rgb-leds-neopixel-esp32-esp8266","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/micropython-ws2812b-addressable-rgb-leds-neopixel-esp32-esp8266\/","title":{"rendered":"MicroPython: WS2812B Addressable RGB LEDs with ESP32 and ESP8266"},"content":{"rendered":"\n<p>This tutorial shows how to control WS2812B addressable RGB LEDs (neopixels) with the ESP32 and ESP8266 using MicroPython. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-micropython-esp8266-esp32.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ws2812b addressable rgb led micropython esp32 esp8266\" class=\"wp-image-81267\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-micropython-esp8266-esp32.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-micropython-esp8266-esp32.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-micropython-esp8266-esp32.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-micropython-esp8266-esp32.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p>There is a built-in library in MicroPython that makes it extremely easy to control these LEDs: the <span class=\"rnthl rntliteral\">\nneopixel<\/span> library. We&#8217;ll show you how to control individual LEDs, create functions to produce awesome lighting effects, and build a simple project to illustrate how everything works.<\/p>\n\n\n\n<p>This tutorial can be applied to any strip or PCB board that has WS2812B addressable RGB LEDs (neopixels) like:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/ws2812b-addressable-rgb-led-strip\/\" target=\"_blank\">WS2812B addressable RGB LED Strips<\/a><\/li><li><a rel=\"noreferrer noopener nofollow\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/ebay.to\/2DGHerd\" target=\"_blank\">WS2812B addressable RGB LED Rings<\/a><\/li><li><a rel=\"noreferrer noopener nofollow\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/ebay.to\/2SCRE5q\" target=\"_blank\">WS2812B addressable RGB LED PCB Sticks<\/a><\/li><\/ul>\n\n\n\n<p>In this tutorial we&#8217;ll control two addressable RGB LED rings, and one addressable LED stick wired in series.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"351\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neipixels-ws2812-addressable-leds.jpg?resize=750%2C351&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"WS2812B addressable RGB LEDs Strips, rings, PCB sticks\" class=\"wp-image-81143\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neipixels-ws2812-addressable-leds.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neipixels-ws2812-addressable-leds.jpg?resize=300%2C140&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neipixels-ws2812-addressable-leds.jpg?resize=510%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 510w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>To follow this tutorial you need to have MicroPython firmware installed in your ESP32 or ESP8266. You also need an IDE to write and upload the code to your board. We suggest using Thonny IDE or uPyCraft IDE:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Thonny IDE:<ul><li><a href=\"https:\/\/randomnerdtutorials.com\/getting-started-thonny-micropython-python-ide-esp32-esp8266\/\">Installing and getting started with Thonny IDE<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/flashing-micropython-firmware-esptool-py-esp32-esp8266\/\">Flashing MicroPython Firmware with esptool.py<\/a><\/li><\/ul><\/li><li>uPyCraft IDE:<ul><li>Install uPyCraft IDE (<a href=\"https:\/\/randomnerdtutorials.com\/install-upycraft-ide-windows-pc-instructions\/\">Windows<\/a>, <a href=\"https:\/\/randomnerdtutorials.com\/install-upycraft-ide-mac-os-x-instructions\/\">Mac OS X<\/a>, <a href=\"https:\/\/randomnerdtutorials.com\/install-upycraft-ide-linux-ubuntu-instructions\/\">Linux<\/a>)<\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/flash-upload-micropython-firmware-esp32-esp8266\/\">Flash\/Upload MicroPython Firmware to ESP32 and ESP8266<\/a><\/li><\/ul><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Introducing WS2812B RGB LEDs<\/h2>\n\n\n\n<p>The WS2812B LEDs are addressable RGB LEDs that can be connected in series, and be controlled individually using just one digital pin of a microcontroller. These LEDs have an IC built right into the LED that make all of this possible.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"256\" height=\"216\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/09\/LED-with-arrow.png?resize=256%2C216&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"addressable ws2812 rgb led neopixel\" class=\"wp-image-26962\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/09\/LED-with-arrow.png?w=256&amp;quality=100&amp;strip=all&amp;ssl=1 256w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/09\/LED-with-arrow.png?resize=150%2C127&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/09\/LED-with-arrow.png?resize=80%2C68&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/09\/LED-with-arrow.png?resize=220%2C186&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/09\/LED-with-arrow.png?resize=119%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 119w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/09\/LED-with-arrow.png?resize=178%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 178w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/figure><\/div>\n\n\n\n<p>You can solder several LED rings and sticks and they will behave as one piece. Each PCB has IN and OUT pins that make wiring very simple:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"449\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixels-ws2812-addressable-leds-pins.jpg?resize=750%2C449&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-81145\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixels-ws2812-addressable-leds-pins.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixels-ws2812-addressable-leds-pins.jpg?resize=300%2C180&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<p>The following figure shows how our setup looks like after soldering the LEDs.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"357\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-wired-series.jpg?resize=750%2C357&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ws2812b neopixel wired in series\" class=\"wp-image-81263\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-wired-series.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-wired-series.jpg?resize=300%2C143&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<p>To wire the RGB LED strip to the ESP32 or ESP8266 is very simple. You need to apply 5V to the <span class=\"rnthl rntcred\">VCC<\/span> pin, GND to <span class=\"rnthl rntcblack\">GND<\/span> and connect a GPIO to the Din (data) pin. We\u2019ll connect the data pin to \n<span class=\"rnthl rntcblue\">GPIO 5<\/span>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Controlling WS2812B RGB LEDs<\/h2>\n\n\n\n<p>There\u2019s a built-in MicroPython module called <em>neopixel <\/em>to control WS2812B addressable LEDs. For example, the next script controls 4 individual pixels:<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Complete project details at https:\/\/RandomNerdTutorials.com\n\nimport machine, neopixel\n\nn = 48\np = 5\n\nnp = neopixel.NeoPixel(machine.Pin(p), n)\n\nnp[0] = (255, 0, 0)\nnp[3] = (125, 204, 223)\nnp[7] = (120, 153, 23)\nnp[10] = (255, 0, 153)\nnp.write()\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP-MicroPython\/esp32_esp8266_ws2812b_individual.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Importing libraries<\/h3>\n\n\n\n<p>First, import the <span class=\"rnthl rntliteral\">\nneopixel<\/span> and <span class=\"rnthl rntliteral\">machine<\/span> modules:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>import machine, neopixel<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create a neopixel object<\/h3>\n\n\n\n<p>Set the number of pixels in your strip to the <span class=\"rnthl rntliteral\">n<\/span> variable:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>n = 48<\/code><\/pre>\n\n\n\n<p>Save the GPIO number that will control the strip on the <span class=\"rnthl rntliteral\">p<\/span> variable:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>p = 5<\/code><\/pre>\n\n\n\n<p>Create a NeoPixel object called <span class=\"rnthl rntliteral\">\nnp<\/span> on the GPIO you\u2019ve defined earlier and with the number of LEDs you\u2019ve also defined:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>np = neopixel.NeoPixel(machine.Pin(p), n)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Controlling individual pixels<\/h3>\n\n\n\n<p>After initializing the neopixel object, you can start controlling the LEDs. Controlling an individual pixel is very easy. You can think of the strip as an array with <span class=\"rnthl rntliteral\">n<\/span>elements (number of pixels in this sample strip). Then, we just need to set a color to a specific element. For example, to set the first pixel to red:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>np&#091;0] = (255, 0, 0)<\/code><\/pre>\n\n\n\n<p>The following figure may help you better understand how it works:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"236\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_micropython.png?resize=750%2C236&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ws2812b control individual pixels micropython\" class=\"wp-image-81150\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_micropython.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_micropython.png?resize=300%2C94&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<p>Then, use the <span class=\"rnthl rntliteral\">write()<\/span> method for the changes to take effect.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>np.write()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"375\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-control-individual-pixels.jpg?resize=750%2C375&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ws2812b control individual pixels micropython\" class=\"wp-image-81264\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-control-individual-pixels.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-control-individual-pixels.jpg?resize=300%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">WS2812 RGB LEDs Lighting Effects<\/h3>\n\n\n\n<p>Now that you know how to control individual pixels, you can make your own lighting effects. We&#8217;ll provide some functions (based on the library examples) that you can use in your own projects.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Clear all pixels<\/h4>\n\n\n\n<p>Clearing all pixels is the same as setting all pixels to (0, 0, 0) color.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def clear():\n  for i in range(n):\n    np&#091;i] = (0, 0, 0)\n    np.write()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"51\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_clear.png?resize=750%2C51&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-81184\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_clear.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_clear.png?resize=300%2C20&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Set all pixels to the same color<\/h4>\n\n\n\n<p>In a similar way, to set all the pixels to the same color, you can use the following function that accepts as arguments, the r, g, and b color parameters .<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def set_color(r, g, b):\n  for i in range(n):\n    np&#091;i] = (r, g, b)\n  np.write()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"107\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_set_color.png?resize=750%2C107&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-81185\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_set_color.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_set_color.png?resize=300%2C43&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Bounce effect<\/h4>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">bounce()<\/span> function creates a bounce effect and accepts the r, g and b parameters to set the color, and the waiting time. The waiting time determines how fast the bouncing effect is.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def bounce(r, g, b, wait):\n  for i in range(4 * n):\n    for j in range(n):\n      np&#091;j] = (r, g, b)\n    if (i \/\/ n) % 2 == 0:\n      np&#091;i % n] = (0, 0, 0)\n    else:\n      np&#091;n \u2013 1 \u2013 (i % n)] = (0, 0, 0)\n    np.write()\n    time.sleep_ms(wait)<\/code><\/pre>\n\n\n\n<p>This effect shows an off pixel that runs through all the strip positions.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"212\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_bounce.png?resize=750%2C212&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-81186\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_bounce.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_bounce.png?resize=300%2C85&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Cycle effect<\/h4>\n\n\n\n<p>The cycle effect works similarly to the bounce effect. There is a pixel on that runs through all the strip positions while the other pixels are off.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def cycle(r, g, b, wait):\n  for i in range(4 * n):\n    for j in range(n):\n      np&#091;j] = (0, 0, 0)\n    np&#091;i % n] = (r, g, b)\n    np.write()\n    time.sleep_ms(wait)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"204\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_cycle.png?resize=750%2C204&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-81187\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_cycle.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_cycle.png?resize=300%2C82&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Moving raibow effect<\/h4>\n\n\n\n<p>To produce a moving rainbow effect, you need two functions. The <span class=\"rnthl rntliteral\">wheel()<\/span> function generates the rainbow color spectrum by varying each color parameter between 0 and 255.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def wheel(pos):\n  Input a value 0 to 255 to get a color value.\n  The colours are a transition r - g - b - back to r.\n  if pos &lt; 0 or pos > 255:\n    return (0, 0, 0)\n  if pos &lt; 85:\n    return (255 - pos * 3, pos * 3, 0)\n  if pos &lt; 170:\n    pos -= 85\n    return (0, 255 - pos * 3, pos * 3)\n  pos -= 170\n  return (pos * 3, 0, 255 - pos * 3)<\/code><\/pre>\n\n\n\n<p>After that, use the <span class=\"rnthl rntliteral\">rainbow_cycle()<\/span> function that uses the results from the <span class=\"rnthl rntliteral\">wheel()<\/span> function to distribute the rainbow across the number of LEDs on your strip.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def rainbow_cycle(wait):\n  for j in range(255):\n    for i in range(n):\n      rc_index = (i * 256 \/\/ n) + j\n      np&#091;i] = wheel(rc_index &amp; 255)\n    np.write()\n    time.sleep_ms(wait)<\/code><\/pre>\n\n\n\n<p>This function accepts as argument the waiting time. The waiting time defines how fast the rainbow effect moves.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"42\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_rainbow.png?resize=750%2C42&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-81189\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_rainbow.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/neopixel_control_leds_rainbow.png?resize=300%2C17&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<p>Knowing how these functions work, you can build your own projects to produce amazing lighting effects. To see how everything works together, in the next section we&#8217;ll build a simple project to control a bunch of addressable RGB LEDs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">WS2812B RGB LEDs with MicroPython: Project example<\/h2>\n\n\n\n<p>Here, we&#8217;ll build a simple circuit with 4 pushbuttons. It will make different lighting effects depending on the pushbutton pressed.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"459\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-project-example-rainbow.jpg?resize=750%2C459&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ws2812b led with esp32 esp8266 micropython circuit\" class=\"wp-image-81266\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-project-example-rainbow.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-project-example-rainbow.jpg?resize=300%2C184&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Parts Required<\/h3>\n\n\n\n<p>In this project we&#8217;re using two addressable RGB LED rings with different sizes and an addressable RGB LED stick. However, you can use an RGB LED strip or addressable RGB LEDs in other configurations.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\">ESP32 <\/a>(read <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\" target=\"_blank\">Best ESP32 development boards<\/a>) or <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp8266-esp-12e-nodemcu-wi-fi-development-board\/\" target=\"_blank\">ESP8266 <\/a>(read <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/best-esp8266-wi-fi-development-board\/\" target=\"_blank\">Best ESP8266 development boards<\/a>)<\/li><li>Addressable RGB LEDs: <ul><li><a rel=\"noreferrer noopener nofollow\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/ebay.to\/2DGHerd\" target=\"_blank\">Ring<\/a><\/li><li><a rel=\"noreferrer noopener nofollow\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/ebay.to\/2SCRE5q\" target=\"_blank\">Stick<\/a><\/li><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/ws2812b-addressable-rgb-led-strip\/\" target=\"_blank\">Strip<\/a> <\/li><\/ul><\/li><li>4x <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/pushbuttons-kit\/\" target=\"_blank\">pushbuttons <\/a>(momentary switches)<\/li><li>4x <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\">10kOhm resistors<\/a><\/li><li><a href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\">Breadboard<\/a><\/li><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\">Jumper wires<\/a><\/li><\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Schematic<\/h3>\n\n\n\n<p>In both ESP32 and ESP8266 we&#8217;ll wire the circuit as follows:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Button 1<\/strong><\/td><td>\n<span class=\"rnthl rntcblue\">GPIO 14<\/span><\/td><\/tr><tr><td><strong>Button 2<\/strong><\/td><td>\n<span class=\"rnthl rntcgreen\">GPIO 12<\/span><\/td><\/tr><tr><td><strong>Button 3<\/strong><\/td><td>\n<span class=\"rnthl rntcyellow\">GPIO 13<\/span><\/td><\/tr><tr><td><strong>Button 4<\/strong><\/td><td>\n<span class=\"rnthl rntclgray\">GPIO 15<\/span><\/td><\/tr><tr><td><strong>Addressable RGB LED data pin<\/strong><\/td><td>\n<span class=\"rnthl rntclblue\">GPIO 5<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"rntbox rntclgreen\"><strong>Note: <\/strong> you can chose any other digital pins, if needed.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">ESP32<\/h4>\n\n\n\n<p>You can also follow the next schematic diagram to wire the circuit for ESP32:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp32_neopixel_project_bb.jpg?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"799\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp32_neopixel_project_bb.jpg?resize=1200%2C799&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"esp32 neopixel pushbutton ws2812b project\" class=\"wp-image-81233\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp32_neopixel_project_bb.jpg?w=1644&amp;quality=100&amp;strip=all&amp;ssl=1 1644w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp32_neopixel_project_bb.jpg?resize=300%2C200&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp32_neopixel_project_bb.jpg?resize=768%2C511&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp32_neopixel_project_bb.jpg?resize=1024%2C681&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">ESP8266<\/h4>\n\n\n\n<p>Follow the next schematic diagram if you&#8217;re using an EPS8266:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp8266_neopixel_project_bb.jpg?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"973\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp8266_neopixel_project_bb.jpg?resize=1200%2C973&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"esp8266 neopixel pushbutton ws2812b project\" class=\"wp-image-81232\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp8266_neopixel_project_bb.jpg?w=1334&amp;quality=100&amp;strip=all&amp;ssl=1 1334w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp8266_neopixel_project_bb.jpg?resize=300%2C243&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp8266_neopixel_project_bb.jpg?resize=768%2C623&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/esp8266_neopixel_project_bb.jpg?resize=1024%2C831&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Code<\/h3>\n\n\n\n<p>Upload the following code to your ESP32 or ESP8266 as <em>main.py<\/em>.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Complete project details at https:\/\/RandomNerdTutorials.com\n\nfrom machine import Pin\nimport machine, neopixel, time\n\n# define interrupt handling functions\ndef button_handler(pin):\n  global button_pressed\n  button_pressed = pin\n\n# configure pushbuttons as interrupts\nbutton1 = Pin(15, Pin.IN)\nbutton1.irq(trigger=Pin.IRQ_RISING, handler=button_handler)\nbutton2 = Pin(14, Pin.IN)\nbutton2.irq(trigger=Pin.IRQ_RISING, handler=button_handler)\nbutton3 = Pin(12, Pin.IN)\nbutton3.irq(trigger=Pin.IRQ_RISING, handler=button_handler)\nbutton4 = Pin(13, Pin.IN)\nbutton4.irq(trigger=Pin.IRQ_RISING, handler=button_handler)\n\nbutton_pressed = button1\n\n# LED strip configuration\n# number of pixels\nn = 48\n# strip control gpio\np = 5 \nnp = neopixel.NeoPixel(machine.Pin(p), n)\n\n# FUNCTIONS FOR LIGHTING EFFECTS\n# bounce\ndef bounce(r, g, b, wait):\n  for i in range(2 * n):\n    for j in range(n):\n      np[j] = (r, g, b)\n    if (i \/\/ n) % 2 == 0:\n      np[i % n] = (0, 0, 0)\n    else:\n      np[n - 1 - (i % n)] = (0, 0, 0)\n    np.write()\n    time.sleep_ms(wait)\n\n# cycle\ndef cycle(r, g, b, wait):\n  for i in range(n):\n    for j in range(n):\n      np[j] = (0, 0, 0)\n    np[i % n] = (r, g, b)\n    np.write()\n    time.sleep_ms(wait)\n\n# function to go through all colors \ndef wheel(pos):\n  # Input a value 0 to 255 to get a color value.\n  # The colours are a transition r - g - b - back to r.\n  if pos &lt; 0 or pos &gt; 255:\n    return (0, 0, 0)\n  if pos &lt; 85:\n    return (255 - pos * 3, pos * 3, 0)\n  if pos &lt; 170:\n    pos -= 85\n    return (0, 255 - pos * 3, pos * 3)\n  pos -= 170\n  return (pos * 3, 0, 255 - pos * 3)\n\n# rainbow \ndef rainbow_cycle(wait):\n  for j in range(255):\n    for i in range(n):\n      rc_index = (i * 256 \/\/ n) + j\n      np[i] = wheel(rc_index &amp; 255)\n    np.write()\n    time.sleep_ms(wait)\n\n# turn off all pixels\ndef clear():\n  for i in range(n):\n    np[i] = (0, 0, 0)\n    np.write()\n\nwhile True:\n  if button_pressed == button1:\n    clear()\n  elif button_pressed == button2:\n    bounce(23, 210, 15, 70)\n  elif button_pressed == button3:\n    cycle(123, 0, 154, 50)\n  elif button_pressed == button4:\n    rainbow_cycle(1)\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP-MicroPython\/esp32_esp8266_ws2812b.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the Code Works<\/h3>\n\n\n\n<p>Continue reading this section if you want to learn how the code works. Otherwise, you can skip to the &#8220;Demonstration&#8221; section.<\/p>\n\n\n\n<p>Start by importing the necessary libraries:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>from machine import Pin\nimport machine, neopixel, time<\/code><\/pre>\n\n\n\n<p>The pushbuttons will be set as interrupts. So, we need to create an interrupt handling function that will run every time an interrupt happens &#8211; in this case, the <span class=\"rnthl rntliteral\">button_handler()<\/span> function.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def button_handler(pin):\n  global button_pressed\n  button_pressed = pin<\/code><\/pre>\n\n\n\n<p>The interrupt handling function has an input parameter (<span class=\"rnthl rntliteral\">pin<\/span>) in which an object of class <span class=\"rnthl rntliteral\">Pin<\/span> will be passed when the interrupt happens. This allows us to know which pin generated the interrupt.<\/p>\n\n\n\n<p>In our example, the handle interrupt function is called <span class=\"rnthl rntliteral\">button_handler<\/span> and it saves the pushbutton that was pressed on the <span class=\"rnthl rntliteral\"> button_pressed<\/span> variable. <\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def button_handler(pin):\n  global button_pressed\n  button_pressed = pin<\/code><\/pre>\n\n\n\n<p class=\"rntbox rntclgreen\"> <strong>Note: <\/strong> <span class=\"rnthl rntliteral\">button_pressed<\/span> is defined as a global variable, because we want it to be accessible throughout all the code, not just inside of the <span class=\"rnthl rntliteral\">button_handler()<\/span> function.<\/p>\n\n\n\n<p>After that, configure the pushbuttons as interrupt pins:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>button1 = Pin(15, Pin.IN)\nbutton1.irq(trigger=Pin.IRQ_RISING, handler=button_handler)\nbutton2 = Pin(14, Pin.IN)\nbutton2.irq(trigger=Pin.IRQ_RISING, handler=button_handler)\nbutton3 = Pin(12, Pin.IN)\nbutton3.irq(trigger=Pin.IRQ_RISING, handler=button_handler)\nbutton4 = Pin(13, Pin.IN)\nbutton4.irq(trigger=Pin.IRQ_RISING, handler=button_handler)<\/code><\/pre>\n\n\n\n<p>By default, the <span class=\"rnthl rntliteral\">button_pressed<\/span> variable is equal to <span class=\"rnthl rntliteral\">button1<\/span>, because this button clears the LEDs and we want them to be off by default.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>button_pressed = button1<\/code><\/pre>\n\n\n\n<p>Then, we create a neopixel object on \n<span class=\"rnthl rntclblue\">GPIO 5<\/span>, with 48 LEDs. You should change the <span class=\"rnthl rntliteral\">n<\/span> variable with the number of LEDs you are controlling.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>n = 48 # number of pixels\np = 5  # strip control gpio\nnp = neopixel.NeoPixel(machine.Pin(p), n)<\/code><\/pre>\n\n\n\n<p>After that, we define the functions we&#8217;ve seen in a earlier section: <span class=\"rnthl rntliteral\">bounce()<\/span>,<span class=\"rnthl rntliteral\">cycle()<\/span>, <span class=\"rnthl rntliteral\">wheel()<\/span>, <span class=\"rnthl rntliteral\">rainbow_cycle()<\/span>,and<span class=\"rnthl rntliteral\">clear()<\/span>.<\/p>\n\n\n\n<p>In the while loop, we check which button was pressed and call a different function depending on the button pressed:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Button 1: clears the strip (all neopixels off)<\/li><li>Button 2: bounce effect<\/li><li>Button 3:cycle effect<\/li><li>Button 4: rainbow effect<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>while True:\n  if button_pressed == button1:\n    clear()\n  elif button_pressed == button2:\n    bounce(23, 210, 15, 10)\n  elif button_pressed == button3:\n    cycle(123, 0, 154, 20)\n  elif button_pressed == button4:\n    rainbow_cycle(1)<\/code><\/pre>\n\n\n\n<p class=\"rntbox rntclgreen\"><strong>Note: <\/strong> you can change the arguments of the previous functions to set the LEDs in different colors or adjust the <span class=\"rnthl rntliteral\">wait<\/span> parameter to make the effect faster or slower.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>After uploading the previous code to your ESP32 or ESP8266 as <em>main.py<\/em>, press the ESP Enable\/Reset button to run the new code.<\/p>\n\n\n\n<p>Press each pushbutton to produce different effects. You can watch the video below for a live demonstration:<\/p>\n\n\n\n<p style=\"text-align:center\"><iframe width=\"720\" height=\"405\" src=\"https:\/\/www.youtube.com\/embed\/FVTeNYZgVM8?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n\n\n\n<p class=\"rntbox rntclgreen\"><strong>Note: <\/strong> when you press the pushbutton to select an effect, it will only start when the effect that is running stops.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial you&#8217;ve learned how to control WS2812B addressable RGB LEDs (rings, strips, or sticks). Controlling these LEDs with MicroPython is simple thanks to the <span class=\"rnthl rntliteral\">neopixel <\/span>library. You&#8217;ve also learn how to set multiple interrupts with MicroPython.<\/p>\n\n\n\n<p>Now, you can apply the concepts learned in this tutorial in your own projects. For example, you can build a web server with different buttons that controls the LEDs remotely.<\/p>\n\n\n\n<p>We have more tutorials about RGB LEDs that you may like:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/electronics-basics-how-do-rgb-leds-work\/\">How do RGB LEDs work?<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/node-red-with-ws2812b-addressable-rgb-led-strip\/\">Node-RED with WS2812B Addressable RGB LED Strip<\/a><\/li><\/ul>\n\n\n\n<p>Other tutorials about MicroPython and ESP32 and ESP8266:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong><a href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-with-esp32-and-esp8266\/\">[eBook] MicroPython Programming with ESP32 and ESP8266<\/a><\/strong><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-mqtt-esp32-esp8266\/\">MicroPython \u2013 Getting Started with MQTT on ESP32\/ESP8266<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-gpios-esp32-esp8266\/\">MicroPython with ESP32 and ESP8266: Interacting with GPIOs<\/a><\/li><\/ul>\n\n\n\n<p>\n\nWe hope you enjoyed this project and learned something new. \n\n<\/p>\n\n\n\n<p>Thanks for reading. <br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to control WS2812B addressable RGB LEDs (neopixels) with the ESP32 and ESP8266 using MicroPython. <\/p>\n<p class=\"read-more-container\"><a href=\"https:\/\/randomnerdtutorials.com\/micropython-ws2812b-addressable-rgb-leds-neopixel-esp32-esp8266\/\" class=\"read-more button\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":81267,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[281,265,310,309,264],"tags":[],"class_list":["post-81128","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32-project","category-esp8266-project","category-micropython","category-0-esp32-micropython","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/ws2812b-micropython-esp8266-esp32.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/81128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=81128"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/81128\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/81267"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=81128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=81128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=81128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}