Arduino Web Enabled RGB Lighting




I just happened to see some large strips of LED lighting when I was picking up some parts at Maplin which were on sale (if I remember correct they were around £12 per approx. 2m strip) however the controller/driver was still around £40, so I thought I would just build a better one myself.
I wanted it to be a web enabled controller as there are a lot of cool things that can be done with a device once it is accessible over HTTP, and I am working on a home automation server project so it would be good to have some devices which I can test this with.

Anyway, let's get started, here is a basic parts list, some of the components may change depending on the nature of your lighting installation (i.e. if you are driving more LEDs you may need higher power transistors, etc.):
  • Arduino (Duemilanove, Uno, etc., can be done with a Mega but it is overkill)
  • Ethernet Shield
  • 12v to 5v switchmode DC-DC converters (my LED strips rat at 12v but the Arduino needs 5v and this is more efficient than a linear converter)
  • Assorted resistors (for transistor protection, usually around 100-500 ohms)
  • NPN transistors (I just used basic NPN transistors as I was only switching around 300mA per channel)
  • Push to make button
  • Various connectors and cables
  • Stripboard (goes by various other names, I used this to make my driver circuit into an Arduino shield)
  • Enclosure (optional but recommended)
  • Fuse and fuse holder (optional but highly recommended for permanent installations)
  • Scrap materials to make any mounting hardware needed (I used HIPS to mount my Arduino in the enclosure)
Tools I used which would help:
  • Soldering iron
  • Multimeter
  • Small flat screwdriver
  • Small posi-drive screwdriver
  • Laser cutter (drills and a file will suffice if you don't have access to one)
All the code for this project is available at this GitHub repo.

Here is a quick demo of my installation at uni using an Android app for control:

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: LED Driver Circuit

NOTE: Please read the next two steps before starting any work mentioned here, I had to do some modification to my original shield because of power issues, they are described on the next step.

Here you will want to build the driver circuit depicted in the schematic below, this can be done in the same way I did it and made into a shield to stack on top of the Arduino and Ethernet shield, or can be a separate board, either way will work, but I don't see any advantage to not making it as a shield.

Some minor points, you will want to have three power cables coming from your shield:
  • One +12v cable going to the 12v pin on the LED strip output
  • One +5v pin going to the 5v pin on the Arduino, and
  • One ground going to the ground pin on the Arduino
The reason for this is explained in the next step.

There are some good guides to building a shield from scratch using stripboard on YouTube, alternatively you could use a (semi) pre-built prototyping shield.

Step 2: Circuit Assembly and Testing

By this time you should have your driver board or shield made, the next step is to test it over a long period of time (a couple of hours in my case) to make sure it is both working properly and efficiently.

Initial testing of my driver circuit before I assembled it on the stripboard:

I mention efficiency because as you can tell by the image below I am supplying the Arduino with 12v via it's on board barrel jack and using this to drive the LEDs via the Vin pin on the Arduino, this means that the Arduino must convert 12v to 5v via it's linear converter, which got very hot after an hour or so.

As a result of this I decided to use a switchmode  DC-DC converter to step the 12v down to 5v for the Arduino and supplied it via the 5v pin. completely bypassing the Arduino's linear converter, to do this I had to modify my shield slightly to redirect the 12v supply for the LEDs and to add cables going to the 5v and ground pins on the Arduino.

The 12v supply for the LEDs will go directly after the main power switch, ground will go to ground and the 5v will be from the output of the DC-DC converter, in my controller I used an isolated DC-DC converter (i.e. the input ground is isolated from the output ground) as I had them left over from audio electronics, however this is not important for this so a regular 3 terminal converter would also be fine.

I also have a push button which toggles the LEDS between off, full on and the last setting set using the web service, once pushed it will change the lights using the last used (or default if not set) transition and transition time. You do not have to use this button, no changes to the code are needed to disable it, if you do want to use it all it has to do is switch an Arduino pin to ground.

Step 3: Arduino Script and Webservices

Now to configure the Arduino script and upload it to your board, there are several important changes that may need to be made:
  1. Pin constants
    On lines 12-15 there are four constants which define the pins to use for the red, green and blue channels as well as the input pin for the quick set button.
    The pins for the colour channels must be set to PWM enabled pins, the pin for the button can be anything other than pin 13 (as pin 13 is a pain to use for inputs with a pull up resistor), 0 and 1 (as serial is used for debugging)
    If you do not want to use the quick set button then you can leave the default value of 12 (assuming this pin is not used for anything else).
  2. MAC and IP
    On lines 42 and 43, set them as suites your network.
    Default gateway and subnet mask are obtained through DHCP.
  3. Default transition and transition time
    You may want to reset the default transition and transition time that is used after the controller is powered on before it is manually set.
    To do this change the constants on lines 34 and 35, a set of valid values for DEFAULT_TRANSITION can be found on lines 24-26.
That should be everything, upload that to your Arduino and give it a test by visiting the web UI in your browser.

The template Arduino script can be found in the GitHub repo.

Step 4: Assemble in Enclosure

When you have concluded that all is good with your controller it's time to put it in a nice enclosure, in my case I got a nice one from Maplin, I believe it is ABS and is designed to be panel mounted (although I never have used it like this, yet).

The design of the mounting hardware and cut out sections will vary greatly with the enclosure, however I have included all of my CAD drawings in the GitHub repo (although they are all 2DDesign files, sorry, I have switched to LibreCAD for all future projects now).

If you designed your controller to switch higher loads then you may want to check what it's heat output is like and decide for yourself whether you need any heatsinks or forced air cooling or not, in my case I added the facilities to include a fan and the ability to run it at both 12v or 5v yet I didn't think it was needed, nonetheless it is good to have vents in the case anyway.

I decided it was a good idea to include a fuse between the +12v supply from the barrel jack and the main power switch, I just used the standard 20mm automotive inline fuse holders, although any type would be just as good, I did look at panel mount holders but they were surprisingly expensive compared to the inline type I am using.

As for fuse rating, I went with 630mA, each channel drew between 100 and 120mA and the Arduino and Ethernet shield will be around 300mA so this rating is a little low if anything, although I have not had a fuse blow yet.

Step 5: Install

As for installing the lighting this will  greatly depend on where you are installing it, the LED strips I had can be chained together by connecting one end of a strip to another, but in my case I stuck each of the LED strips under a shelf above my desk (as they had a self adhesive backing) and ran 4 wires for each LED strip back to the controller which sat on my desk (you get a better idea from the photos).

I suppose the only big considerations are:
  • Making sure the LED strip has a descent amount of room for airflow
    The strips will get warm after being on for a while, if not to keep the LEDs cool to reduce fire risk, increase electrical efficiency and prolong the life of the LEDs (all valid but negligible effects of keeping them well ventilated) then do it to keep the adhesive backing cool so that it does not lose adhesion and cause the LED strips fall off (which did happen to me a couple of times, only on the bottom one which got the heat from my monitors and the annoyingly always on radiator).
  • If you are driving a large chain of LEDs then check to see if the strips have a maximum chain length
    This may be important when the total load of the LEDs down the chain exceeds the maximum rated current for the conductors in the LED strip, which will generate excess heat, reducing efficiency and possible becoming a fire risk.
When you have it all installed, power it up and enjoy being able to control your lights without having to get up!
I admit, it does not sound that impressive, but check the next step for other cool things you can do with it...

Step 6: Extra - Cool Stuff

Here are a few cool things I did with my LED lighting (and some still in progress):
  • Control using an Android app
    I wrote a basic Android app which recreates the functionality of the web UI in a native app.
    The APK and source can be downloaded from the GitHub repo.
    Note: you need to configure the HTTP POST service URL in the settings before you can use the app (details are in GitHub readme)
  • Make it react to music
    I wrote a little Processing script (which unfortunately I seem to have lost) which used the Minim FFT to make each colour (red, green and blue react to a different frequency range in the audible spectrum.
    I did this using both the HTTP POST API and a modified Arduino script using RS232 to control the LEDs.
    Using HTTP POST:

    Using RS232:

  • Do your own thing
    The HTTP POST API is documented on the GitHub repo if you want to make your own cool apps.
  • Home Automation
    I am currently working on a home automation server project which used MQTT and this will make a good testing device to be controlled by the server (if this project interests you then you are more than welcome to contribute to it, send me an email if you are interested, or have a look at my blog if you just want to see how I'm getting on).
Remote Control Contest

Finalist in the
Remote Control Contest

Arduino Contest

Participated in the
Arduino Contest

Epilog Challenge V

Participated in the
Epilog Challenge V

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    26 Discussions


    2 years ago

    Hi. Great project. Will this control the rgb strip from internet radio, or streamed audio? I'm new to everything and have been digging for a way to control my rgb's by internet radio music. I used minim to read an mp3 but can not figure out how to use the streaming audio. So I could probably benefit from your input.



    3 years ago

    Hi DanNixon, congratulations for a nice project, I am trying to control RGB leds using the app but I could not get it. I tried configuring with many options typing IP, port, /service; without success. I hope that you can support me.


    4 years ago

    Hi, thanks for a great tutorial, it helped me a lot!
    One question, I tried the apk and it works great, however I tried to implement http post task in Tasker, did you have a chance to try it, because for some reason it won't work.



    Reply 4 years ago on Introduction

    It states what pin the mode change button is attached to, IIRR this should be pulled low.
    It switches between off, white and the last colour set of the web interface.
    See line 370 for when it is polled.


    Reply 4 years ago on Introduction

    thanks for the clarification, but in your diagram where is connected pin 12 ?


    5 years ago

    Hello Dannixon you've make a extraordinary project it's that as I search all this mount I have now found I need for controlling my rgb strip (10 meter) that's great when I will have a times I will more interesting by this project that's really great good job!


    5 years ago on Step 3

    the default ip adress is also hardcoded in the frontEndHTML on line 141 and 147.
    it took me a while to debug why the web interface didn't respond to the changes

    1 reply

    does it works on public (wan) network? or its only for local network?
    and, do we have to fill ip address of arduino in service url?

    3 replies

    Reply 5 years ago on Introduction

    It could work via port forwarding, although there is no authentication so you may want to use VPN if you want to use it externally.
    The IP addresses will have to be updated to whatever you set the IP of the Arduino to.


    Reply 5 years ago on Introduction

    i was unable to run my app. so what should i write within these quotes?
    WebServer webserver("",8032);
    also, what should i fill in service url (preferences) of android application?


    Reply 5 years ago on Introduction

    I really need more information than that.
    The first parameter to webserver is the root URL, you almost certainly don't need to change it.
    The Android app needs the URL of the XML service, usually http://[ARDUINO_IP]:[PORT]/service
    Where in this case PORT is 8032, you can check this URL in your browser.


    very cool project. thanks a lot for posting the complete files which are hard to get over internet. But, being a newbie i am facing several problems. When i am uploading the code into arduino, I m getting-
    " 'WebServer' doesnot name a type "
    also... this.....
    WebRGB_LED:215: error: 'WebServer' has not been declared
    WebRGB_LED:215: error: expected primary-expression before 'char'
    WebRGB_LED:215: error: expected primary-expression before 'bool'

    so, what should i write within these quotes -
    WebServer webserver("",80);

    thanks in advance...

    1 reply

    Reply 5 years ago on Introduction

    I can say with almost certainty there is something wrong with your copy of the Webduino library (


    6 years ago on Introduction

    that is great. could you please to provide tutorial to control rgb led through internet but arduino is not setting as webserver. then control it using android app. i try to make it but right now still get stuck at json parse point.

    3 replies

    Reply 6 years ago on Introduction

    So you are having trouble accessing the Arduino webserver?
    Have you tried running any of the sample scripts from the webserver library? I would start here, this will eliminate any problems caused by your Arduino, Ethernet Shield or network.
    Let me know how you get on.


    Reply 6 years ago on Introduction

    yes i did. I tried without arduino firstly, running web socket test script to know wether the web server work or not. It runs well. I run my led sketch separately also(without internet). I used tornado web server that provide web socket connection. my notion is control arduino using serial connection -> websocket, then parsing the data with json. so android app can import that data as well.


    Reply 6 years ago on Introduction

    I'm sorry you have completely lost me on what you are attempting to do.
    There is no serial data connection on this, it is all done over the XML webservice.
    You do not need to run a separate webserver for this, the server runs on the Arduino.
    You will need an internet connection to use the on board web UI (at least the client will), as it used jQuery, the libraries fro which are downloaded from the jQuery website by the client when the page loads.