In between the prototyping and the 3d printing and the sleeping, I've been working on an API to control the lights remotely. I may have gone a tiny bit overboard with the amount of features I ended up supporting, but I think it will be worth it.
You can find all the code here: https://github.com/SharpCoder/wifi-neo-pixels
(I'm working on documenting my code and adding a README. It'll be there eventually).
Here is what that code gets you:
- LED Management
- Modes
- The concept of "modes". You can think of a mode as sort of like a shader in video games. It is a bit of code which will execute each cycle for a given LED. Each LED gets some persisting contextual information about itself as well as the system in general.
- I ported the Adafruit "Rainbow" code into one mode.
- Added a "Pulse" mode which is basically fade in / fade out.
- Added a "Blink" mode which - afaik - doesn't work for some reason. It's not that cool anyway...
- In addition to these core modes, it's easy to write more. All you need to do is implement a straightforward interface and the sky's the limit!
- Individual LEDs
- You can set the color (r,g,b) for an individual LED
- You can turn an individual LED on or off
- You can adjust the delay with which the LEDs mode will be invoked
- System
- You can adjust brightness of the whole strand
- Modes
- Web API
- Supported Routes
- /led/{index}/color/{r}/{g}/{b}
- Set individual LED to a specific color
- /led/{index}/visibility/{value}
- Set individual LED on or off
- Value is numeric. 1 for on. Anything else for off.
- /led/all/color/{r}/{g}/{b}
- Set all LEDs to a specific color
- /led/all/visibility/{value}
- Set all LEDs on or off
- /system/brightness/{value}
- Set the brightness for all LEDs on the system
- Value is a number between 0 - 255 inclusive.
- /system/mode/{mode}
- Set the mode for a whole strand. Modes include:
- Rainbow
- From the Adafruit NeoPixel example code
- Blink
- Blink on and off
- Pulse
- Fade in and out infinitely
- Default
- Solid color
- Rainbow
- Set the mode for a whole strand. Modes include:
- /led/{index}/color/{r}/{g}/{b}
- Supported Routes
The device I have this running on is an ESP-12E (Node MCU). I picked up a 4-pack for a shocking 19$ USD. I'm pretty shocked at how cheap these things are because they seem to be amazing so far for my needs. (Find them here on Amazon)
Anyway, I'll conclude this update with a brief explanation for how to use my code.
Step 1 - configure the port / SSID / password
This is done in the file webServer.h - at the top, you can tweak the #defines.
Step 2 - That's basically it. Just flash your 8266-compatible arduino (with supported Adafruit NeoPixel and relevant esp8266 libraries included) with my .ino file and the modifications made to the #defines and you should be up and running!
As soon as your board connects to the WiFi, it will stage a server and expose the routes that I have listed above.
I can't wait to see the neo pixels actually mounted to some panels! That's going to happen very soon. Stay tuned!
Here is a silly, uninformative video demonstrating the neopixel lights changing color as I click things on my browser.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.