How it works

You start by accessing the IP address of the Arduino (Ethernet Shield) from your browser of choice, at which moment you’re presented with a mobile-ready webpage that looks something like this: a few buttons for your favorite colors and three text fields right below to input any RGB value you want.

Anyway, you select one of the colors, and then the software will encode the RGB color combination as an HTTP GET request, effectively sending the r, g, and b values back to the Arduino, as you can see at this point by checking the URL address:

http://192.168.1.52?r=255&g=255&b=255

After receiving the aforementioned request, the Arduino will generate the corresponding DMX signal to the decoder whose only job will now be to power up the LED strips to the expected color.

Step 2: Hardware Setup

Let’s start with the power side of things. Typically in a higher-power LED installation, you’d connect the lights to the 12V power supply of your choice and be done with it. However, in this case, we’ll place the DMX decoder in between, so now the power supply powers up the DMX box and then the LED strips plug into its output.

My specific DMX decoder has 3 pins for DMX input, corresponding to GND reference voltage and D+ and D- signals. Here’s where that 3-wire cable hooks up, connecting the box to the Arduino and electronics.

On the other side of the setup resides the Arduino Mega microcontroller attached to the Ethernet Shield. The board is also connected to a breadboard, which houses all the electronic components, along with 9V power and a Cat-5 Ethernet cable.

Step 3: Electronics

Next up, the electronics. There's no soldering or anything, just a few jumper wires to put this all together in a breadboard.

The whole circuitry is shown in the Fritzing diagram. As explained here, here, and there, this combination of a MAX485 transceiver, a 100Ω resistor, and a couple jumper wires will handle the conversion from the digital output of the Arduino to an electrically-compliant RS-485DMX512 signal.

Step 4: Software Setup

Finally, now that we're done with the hardware side of things we can switch our focus to the software that's running on the microcontroller. If you prefer git-cloning to copy-pasting, you can easily do so as the source code is now available as a repository on GitHub.

The center piece is the library DmxMaster (formerly DmxSimple) by TinkerKit. Once installed via the downloaded *.zip file, it will be responsible for generating the digital output off PIN #3 that plugs into the transceiver to generate the aforementioned DMX signal.

As you can see above, it consists of 9 direct-access-to-color buttons, a form with 3 text fields for custom RGB input, and an extra large button for turning the lights off. Here's the full code (for syntax highlighting, click here):

As a final remark, you can see that jQuery scripts and styles are downloaded from a CDN instead of being read from the SD card. That's because this approach is simply put waaay faster. And if one day the internet connection cuts out, the webpage will keep working; it just won't look this fancy.

Step 6: The Arduino Sketch: Final.ino and Debug.ino

All this code comes together in the Arduino sketches, a.k.a. the "C++" scripts to be compiled on the microcontroller. If you're new to the Arduino world, this is as simple as writing your code using the open-source IDE, plugging in your board with a USB type-A to type-B cable, selecting the appropiate board model and serial port, and clicking "Upload".

When programming, you just need to keep in mind what libraries to include (DmxMaster, Ethernet, SD) , and whether your code should run once (inside setup), indefinitely (inside loop), or be available globally (outside of any function). Here's the full code, with additional commentary (for syntax highlighting, click here):

Step 7: Voice Control Via "Ok, Google"

If you have followed the instructions up until now, you should already have a fully functioning system. The final—and optional— step is to get the lights to turn on by using your voice.

For this to work, you'll need an Android phone with the Google app installed. You'll also need to download Tasker and the AutoVoice plugin. Everything is explained better in the video, but here's a summary:

First of all, make sure the "Ok, Google" command is enabled on your phone by opening the Google App > Settings > Voice > "Ok Google" detection and turning on the first two options. Also grant AutoVoice access to allow for the Google Now integration by going to Settings > Accessibility.

If you've never used Tasker before, here's an introduction. And step-by-step:

Open up Tasker

Create a new profile with the bottom-right "+" button

Choose Event > Plugin > Autovoice > Recognized

For the configuration, speak your voice command (i.e., "turn on the lights") by selecting "Speak filter"

After saving the changes, go back to the profiles tab, and a pop-up menu will show up; choose "New Task"

Name it as you like and then click the bottom "+" button

When asked to select an action, search for "Browser URL"

Fill in the URL field with the IP address of your arduino followed by the GET request with any RGB values you like. I chose the equivalent to the "Clear" button from the webpage, like this:

http://192.168.1.52/?r=255&g=128&b=50

You can now repeat the same steps for the "turn off the lights" command and any others you'd like to have. Once you're done, you should see something like the above in the profiles tab.

And... that's it. Next time you feel like adding some ambient light, just shout out to your phone "turn on the lights!"... and there will be light.

Step 8: You're Done!

By following this guide you should have been able to build a system that allows for easy control of your RGB LEDs from your web browser or phone via the DMX protocol. If you run into any issues, just let me known in the comments down below and will see what I can do.

I've been using this setup for over a year and it's been rock solid. So far it has only stopped working because of power outages or because someone (read: not me) has kicked the Arduino board and some of the wires have disconnected.

Regarding power outages there's not much I can do, but either 3D-printing a case for the system (Arduino + breadboard) or soldering it into a PCB would make it more resistant, plus dust-proof.

Remember to check the full blog post for even more... and if you've got any ideas to improve this system just let me know in the comments or tweet them to me!

And as always, just keep hacking.

Comments

I'm not sure to fully understand as this is quite complex. If your goal is to change the light color from a remote device, why are you generating DMX to the controler. The arduino itself is able to furnish pwm on several channels.

So there are certainly other ways to control RGB LED strips with Arduino, but the point of this project was to keep the main hardware setup with the power supply and DMX decoder, and then get a better control experience on top by using the browser or your voice. And I chose to do that by generating DMX.

Now.. if you want to use any kind of different power control, you should still be able to easily integrate the webpage shown on this instructable. Let me know if you want me to expand on this!

Hi, so with an Arduino and a Bluetooth shield, afaik you wouldn't be able to build the whole webpage system. However, if you're only interested in "Ok Google", you could make the Arduino send the DMX signal upon receiving a serial request via Bluetooth... and it looks like this app might help with that.

I haven't tried it, but according to the description, if you link the "Ok Google" command to writing a file called mnt/sdcard/sendtmp.txt in Tasker, you could Serial.read the incoming data on the Arduino (i.e. the RGB color) and then "turn on the lights".