Adafruit IO: Color Your LEDs With a Colorpicker

by rooijra in Circuits > Arduino

248 Views, 0 Favorites, 0 Comments

Adafruit IO: Color Your LEDs With a Colorpicker

signal-2022-10-05-163553_006.jpeg

In this Instructable, you will learn how to control the color of your LED strip online on your Adafruit IO dashboard. ✨

On my Adafruit IO dashboard, I made a colorpicker to change the color of my LEDs. Then I used some Arduino code to connect my NodeMCU with LED strip to Adafruit IO and my Wifi network.

Supplies

signal-2022-10-05-163553_003.jpeg

To do this you will need the following:

  • NodeMCU
  • LED strip
  • Arduino IDE
  • Wifi connection (not 5GHz)

Install Arduino Libraries

dependecies.PNG

To install the right libraries, open your Arduino IDE and go to the library manager. Search for this library: Adafruit IO Arduino, and click on Install. It might tell you that you have some missing dependencies for this library, you can click Install All to install everything you need.  


Set Up You Adafruit IO Account

key.PNG

Next you need to set up your Adafruit IO account. Go to https://io.adafruit.com and click Get started for free to make a free account. After signing up, click the yellow key button in your menu to copy your key and username.

At first, I couldn't find the key in my account settings, you need to click IO in the top navigation to go to the right page. Here you can see your devices and the key will be in the right-top corner. 

Create a Dashboard

colorblock.PNG

On the same page, create a dashboard by clicking Dashboards and choosing New Dashboard. A pop-up will open asking you to give it a name. Then go to this new dashboard and click the gear icon on the right. Now choose create a new block and click color Picker. Next it will ask you to give your block a name, you can name it: color. Now you can change the color of the circle with the color picker. Try it out to see if it works!

Create a New Arduino File

examplefile.PNG

Now it's time to open your Arduino IDE. Click File, choose Examples, choose Adafruit IO Arduino (under Examples from Custom Libraries) and then Adafruit_14_neopixel.

This will open up a new file with some example code. This code connects your LEDs to io.adafruit.com where you just made your color picker. But you have to make a few changes to this code to make it work for you.

To do this, go to the tab config.h. Put in your key and username, then scroll down a bit and also put in your Wifi name and password. This will not work if your Wifi network is 5GHz! If this is the case, you can use your phone as a hotspot, I chose a hotspot with 2.4GHz.

Lastly, switch back to the first tab and change PIXEL_PIN 5 to PIXEL_PIN D5 so Arduino knows your LED is connected to pin D5 on your NodeMCU. 


Upload Your Code

hexreceivedcopy.png

Upload the code to your NodeMCU and check the serial monitor on the bottom of your screen. 

If you get this error: "Upload error: Error: 2 UNKNOWN: uploading error: no upload port provided", it means that you were trying to upload with no port selected. Always select a port under Tools!

If you get this error: "Adafruit_MQTT.h: No such file or directory", that library is missing and you have to install it.

If you uploaded your code successfully and you are connected to the Wifi, you can now change the color of the led with the color picker you made earlier. When the color changes, the serial monitor will print out the hex code that was received from Adafruit IO.

If nothing happens, check if you gave your feed the correct name, or it wont be found. I made a mistake and named it colorpicker, while the code refers to color.

Enjoy!

Enjoy your results and share your project with others! 🎉