LANp – A DIY Arduino network controllable RGB lamp made from scanner parts!

IMG_20140322_162510This is something we have really been meaning to write up. A few weeks ago we ripped out an RGB LED from an old Canon Scanner that was laying around and going to waste. Since then we’ve been playing around with the RGB LED element and decided to put it to good use.

We have come up with LANp – This is an Arduino and Ethernet Shield that controls an RGB LED colour real-time with a Javascript colour picker.

Take a look below for the YouTube video of this working at the bottom of the page!

What’s in it?

  • 1x Arduino
  • 1x Arduino Ethernet/SD Shield
  • 1x Micro-SDHC Card
  • 1x Scanner LED RGB
  • Various jumper wires

This webserver code is based on our previous article, located just here which shows how to set up an SD Card based web server and serve files over a network, with support for AJAX requests.

The LED Scanner bar we have is an QK1-4761 from a Canon PIXMA MP620 – At the time of writing this post there are a few listed on eBay for around £7.

We started by soldering wires on to the pads of the scanner LED. See the photo below, you may have to do some experimenting to find out which is which, but normally there is an R G B and +v pin. This LED operates at 5v (that doesn’t mean yours will though!).

padsAs you can see on the photo to the right; we just soldered wire directly to 4 of the 5 pads – The bottom one isn’t used and the next are R G B +5v going upwards.

Make sure that none of the wires, or soldered joints are touching each other as this will skew the colour of the LED dramatically. It may be worth taping this up after soldering to avoid the wires touching when you’re moving the LED around.

Connect up the Pins to the Arduino; we have used pins 3, 5, 6 for RGB.

The next thing to do is to get an SD Card formatted to a FAT file system for the webserver, this will host our index.htm page that will control the colour picker. The source code for this file is below:

Copy the above code and save it as index.htm to your SD Card. If you are having trouble displaying the web page, make sure to run the Card Info examples to verify that your SD Card is working with the Arduino.

We are using the Flexi Colour Picker by David Durman which is a Javascript based colour picker that supports multiple web browsers; we have put the Javascript inline instead of a separate file so we are not requesting too many files at once from the webserver.

The next thing to do is get the Arduino Sketch code (posted below)

 Note: Make sure you change the Network Settings to match your setup. If you’re not using pins 3, 5 and 6 change these accordingly.

Some things to note; if you just want colour changing and nothing else (e.g. no web server etc.) then you can just copy out the following function:

We re-map the values as it’s backwards to RGB. So it would be 0 for 255 and 255 for 0. This function reverses it and writes out the value to the pins.

The actual web page looks like the following once loaded:

lanmpweb

From here you should be able to change the colour on the picker and watch it change on the LED! It works by sending an AJAX request to the Arduino Webserver every time the mouse is a down state. The code on the Arduino then receives the RGB values and sets the LED bar to the correct colour.

We have made a small YouTube video demonstrating this (sorry about the quality and lighting, it was recorded on a phone!)

 

That’s about all you need to make a network controllable RGB LED lamp! We’ll be making an enclosure for it in the near future to actually make it look like a lamp, but for now all of the basics are there.

If you have any questions, comments or suggestions please feel free to leave a comment below or send us a message on the contact us page.

See you next time!

Email this to someoneShare on Google+Pin on PinterestTweet about this on TwitterShare on RedditShare on Facebook

6 thoughts on “LANp – A DIY Arduino network controllable RGB lamp made from scanner parts!

    • Hi Jeff,

      There is no direct wire to ground; the scanner bar is a common anode led, it has a +5v which all LEDs are connected to and then connected to PWM pins on the Arduino to control the intensity of the light (current sinking).

      Thanks,

  1. Hi,

    your code is very awesome. Exactly that what I was searching for. But I have a Problem.

    I want to control a 5m RGB-strip with this code. And to give to RGB-Strip Power I installed a Relay between the 230V and the external power Supply for the RGB Strip.

    And to control that Pin I need to bring it permanently on HIGH. And their’s the problem.. :D It is fu**ing impossible to find a place where the Pin stays high :D

    I’m not a total noob at arduino coding.. But I don’t get the point if I put a Pin ( int relay) on HIGH in the setup() Routine, it should stay on. shouldn’t it? But it’a not turning on if it’s standing in the setup routine (or only for a few ms)

    than I putted it in-between the Webserver loop. But then, when I’m pressing any random place at the color field, the Pin goes low.. I even can’t understand how something like that is possible?

    Please help me :)

    Actually is my plan to have this server as a server with ethernet at a ethernet place and then I want to pass the r,g,b values to another arduino via 433 Mhz. where is the best place to submit them? At the SetColour Subroutine? :)

    Greets from Germany! :)

    • Hi Flo

      What you’re trying to do just isn’t possible with relays.
      The LEDs are driven by PWM to adjust the brightness. Basically, PWM turns the pin on and off very quickly.
      A relay simply can’t switch fast enough for the PWM duty cycle.

      You can probably get round this by using some sort of fast switching transistor or FET but I’ve no idea which one to advise you on.

      • haha.. No I now what PWM is and I’m not gonna replace PWM with a relay or so.

        I’m using your code for a 5m RGB LED Strip. And this Strip needs a 12 V Power Supply, and I can power it up by closing the Relay.

        The Problem is now, that I could not decline a new Pin and pull it on High, so the LED -Strip is on Power.
        The PWM pins are going each to a MOSFET to handle the whole Strip.

        I freed up some RAM with F()-Makros and _P-attribute for the strstr-Fkt. brought me 848 Bytes of RAM instead of 640 Bytes.

        But from now, forget the pin for the Relay, I’m already a step further. I now don’t want to connect a RGB-LED or -Strip to the Arduino. Just a 433 MHZ Reciver & Collector. And via the VirtalWire.h Library I will send the r, g, b attributes (coming from the Website) to another Arduino. And this Arduino is then powering the RGB-Strip and doing the PWM stuff with some MOSFETs ;)

        The Question is now the following: Where should I place the transmission? in the Subroutine of the SetColor Function? Or somewhere else? And Do you think it is good to transmit it in one step (like the GET process in HTML) or step by step?

        Greets from Germany

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">