Step 2: Hardware Set-up

First we need to make the WS2812B Ledstrip connectable. Grab the soldering machine and wait till it is warm enough to use. Strip the wires and solder them like the image above. I used black for Ground (GND), Red for +5v and white for the digital pin. Connect the wires to the NodeMCU like this:

Finished? Allright, now it is time to connect the HC-SR04 Distance sensor. This sensor already has pins so it will take a little less time. Connect the wires to the NodeMCU like this:

Pins & Wires HC-SR04:Ground - Gnd Vcc - VinEchopin - D0Trigpin - D1

Step 3: Setting Up the Arduino

WS2812B

To program the Arduino we need to connect the NodeMCU to any pc or mac that has the Arduino software installed. To play with the WS2812B Led-Strip we need to download the Fastled Library. This Library will help creating animations and supports a wide range of popular leds.

Installing the Library:

1) Go to https://github.com/FastLED/FastLED/releases and download the library (.zip file)2) Open Arduino Software > Sketch > Include Library > Add .zip library3) Navigate to the .zip file's location and open it. (As shown in the image above)4) Navigate to Sketch > Import Library menu. You should now see the library.

Now we need to run some basic code to see whether the Led-Strip is working or not. This is also the start of our code.

Do something when distance is somethingNow we want to make something happen at a certain distance. By adding the following code it is possible to run code when the distance is less than 20 centimeters from the sensor.

It is also possible to do this with larger than, or even make combinations.

Step 5: Create Something Usefull

Now it is time to use your knowledge to design and create something useful. I tried to show the amount of bottles in a fridge by displaying them on the Led-Strip. (See illustration).

In this example the WS2812B is attached to the refrigerator and the HC-SR04 is placed in the inside of the fridge.The Led-strip changes every time a bottle is taken from the fridge. It turns orange when more than 50% is taken. And all the leds turn red when the fridge is empty.