Hi people!

This time I'm going to show you how to control the light from a old/broken scanner/printer. Maybe you will see, I like to get many things from junk and use in my projects.

Sometime ago I won a old printer from a teacher. Generally when I get something junky, I disassemble them and keep the things that maybe be used for something. From that printer I salvaged the motors, their mechanisms, the source, the scanner sensor and some other little things.

When i got the scanner sensor did not thought of something nice to do, but when scanning some things to study on another printer, I saw that that the scanner had his color changing (yeah, i know,i should leave the cover lowered), and remembered of an article on internet saying this sensors have a RGB led inside them.

Nice! I just had to find where I put the sensor, could be easy....

Step 1: Discovering How to Connect the RGB LED

With the sensor in hands, i had to know how to connect the LED inside. First I had to separate the pcb from the black plastic enclosure( be careful to not break it), then testing with a multimeter I was capable to see that the LED is directly connected to the header, no resistor or nothing, just each pin connected to an LED's terminal. I also discovered that the RGB LED is common anode, this means that its positive terminal is shared to each color and to make a color glow we have to connect the respective cathode(negative terminal) to ground.

Step 2: Connecting the Scanner Light and Arduino.

Since the RGB LED inside the sensor still is a LED, it was connected in the usual way to Arduino, the relative pins at each color must be connected to PWM pins, so we can select the amount of red, green and blue we want the lamp show, the only difference is that this LED is common anode and must have its common pin connected to the 5V instead of GND, and to light one of the colors the relative pin to that color should be put in LOW.

In the first attempt i used 330 ohm resistors in each cathode pin, but this, for an unknown reason didn't work, so I connected the Arduino Nano PWM pins 9, 10 and 11 directly to each LED cathode terminal, and the anode to 5V, this worked fine.

Step 3: The Code.

So, with the scanner light and the Arduino connected we only need a little piece of code to make it glow with nice colors. The code is below, it's well commented, but in next step I will speak a little about how it makes the colors shine.

//Written by Robson Couto
//December 2014
//pins definitions 
#define blue 9
#define red 10
#define green 11
int bluevalue,greenvalue,redvalue,i,j,k; //variables to keep the values
// of the waves in each pin
void setup(){
  pinMode(blue,OUTPUT);//LED pins as output
  redvalue=128; //first color -> red+green=yellow
void loop(){
  redvalue=redvalue+i;//changing the wave in each pin every loop cycle
  analogWrite(red,255-redvalue);//updating the PWM values 
  delay(50);//this can be changed to make the colors change faster or slower 
   if(redvalue==255){ //test if an clor will be increased, decreased or turned off.
     i=-1;            //see the image in the instructable to understand better.

Step 4: Understanding How This Code Works.

What the code does is change between the colors red, green and blue, mixing two colors most of the time, for example see the first image above, when the colors red and blue have the same amount the resulting color is magenta, then blue is decreased and red incread until its maximum resulting only the color red, after that red starts to decrease and green starts to increase while blue is turned off resulting in yellow.

See the second image above to know the resulting color when red, green and blue are mixed.

To change the amount of red, green and blue in the LED, the analogWrite() function is used. To use analogWrite() you need a PWM pin, so each pin of the LED, minus the anode(that is connected to +5V), needs to be conected in a PWM pin. On my Nano I used pins 9,10 e 11.

Another thing, as the LED is common anode, using analogWrite(255) on a pin will turn off that color instead of making it glow, this is because that there is no potential difference between the LED terminals, so to make a color glow in its max is necessary to use analogWrite(0).

Step 5: Make It Glow!

Well done!

Now your have an all-new RGB lamp!

Thanks for reading, see you on another instructable.

<p>It's unsafe to directly connect LED to arduino :) You could use ULN2003 transistor array or just 3 simple NPN transistors to drive that leds without overloading Arduino pins :) And then you could use some small value resistors to secure LEDs from burning :)</p>
<p>Hi Domints: I tested a scanner sensor and located the 4 pins (RGB and common Anode). I was very careful using a low volt battery with a reverse polarity protection diode and 470 ohm all in parallel, till i got them to glow safely...I find your comment very interesting. Can you please provide even a hand sketch how to use ULN2003, even for one LED color and I will take it from there..I just don t wanna kill my only one Arduino outputs, or the LEDs. Thanks.</p>
<p>That's with transistors separately (because I don't have ULN2003 in my Eagle lib), but ULN2003 is just array of 7 transistors in one case - one next to each other with grounds connected internally, exposed collectors and bases of each transistor.</p>
<p>True. Arduino pins cannot source much current (I believe a maximum of 40mA, depending on the chip), therefore a transistor (or MOFSET, depending on the power requirements) is the safer way to go.</p>
<p>Yeah, you're right! ;)</p><p>Thanks for the tip.</p>
<p>From Step 1: &quot;..then testing with a multimeter I was capable to see that the LED is <br>directly connected to the header, no resistor or nothing, just each pin <br>connected to an LED's terminal.&quot;</p><p>How did you determine this exactly?</p>
<p>Very nice!</p>
Thanks for the instructable, think I might add some potentiometers with analog read to set color values and use as a sort of desk lamp double sided taped under a hutch or something; need to check on getting a couple arduino micros, for simple, fun things like this.
<p>Cool! Thanks for posting!</p><p>Arduinos minis also are good for this, and they can be really cheap if compared to its big brothers.</p>
<p>Wawoo wawoo wawooo...man I have a scanner sensor for few years waiting for something useful to do. It was to neat to be thrown away. You made my day today. many thanks..please keep posting, I am gonna follow ya.</p>
<p>You're welcome! </p><p>Don't forget to put an image here and hit &quot; I made it!&quot;.</p>
<p>I think RGB LED string in scanner/copier sensor unit is desined for cycle-by-cycle operation that means having time enough to dissipate certain amount of heat between the cycles. Converting it to night luminaire you presume it to run constantly. What about overheat? </p><p>From the ather hand, the &quot;prepared&quot; sensor turns outside of the scanner/copier chassis, well this point may compensate possible overheating in a constant light source' mode...</p>
<p>Yeah, but i left it on all the morning when making this instructable and didn't see any signal of overheating, and it still works.</p><p>Anyway, this sensor would be on trash if I not had taken it, it i had burned it, at least I would learn something.</p>
<p>Cool idea, now you have to try to make a night light with this scanner idea.</p>
<p>Thanks! Yeah, you're right.</p>
<p>Wow its really cool idea :)</p><p>I always love reusing old stuffs.Thanks for sharing.</p>
<p>Thank you ;)</p><p>You're welcome! Wait for more.</p>
<p>Nice project.</p><p>I also wanted to reuse the LED strip from a scanner.</p><p>If you are careful, you can gently separate the LED bar and Scanner PCB from the plastic housing. You can then unsolder the white LED module from the Scanner PCB.</p><p>Just use sidecutters to crack the black housing, being extra careful around the 4 pin connector (the LEDs are in the section just above the pins).</p><p>I broke the first one I attempted, second one was easier.</p>
<p>Thanks for the tip! </p><p>I did not mention that i separate the pcb from the plastic housing, now i fixed that, thank you. </p><p>What will you do with your LED strip?</p>
<p>Good instructable, nicely thought out. Usefull rework. With the use of a 555 for the pwm and a transistor for increased current it would make a nice adjustable under counter light! </p>
<p>Thanks for the kind words.</p><p>Nice idea about using 555!</p>
<p>How did you test with a multimeter?</p>
<p>I used the cotinuity test, i think that most multimeters have this, but i'm not sure.</p><p>So I was putting a test lead in one of the LED's terminals and the other test lead in every pin of the sensor's header until i heard the sound. When i heard the sound means the that pin on the header is connected to that LED terminal.</p><p>I hope this helps. </p>
<p>Interesting. I also have one of these, and I've found a few color combinations by experimentation with a 9v battery. Do you plan to make it into a stand alone lamp? Possibly one with color selection buttons?</p>
<p>Yes, but first I need an spare atmega, or better, an attiny to control the colors, becuase these chips are a lot chaeper than an complete Arduino board.</p>
<p>Whoa, very cool!</p>
<p>Thank you Seamster.</p>

About This Instructable




Bio: A eletrical engeneering student, video games lover and hardware aficionado. Starting my journey through the world of electronics. Microcontrollers?! I love them!
More by Robson Couto:Raspberry Pi - GPIOs, graphical interface, pyhton, math, and electronics. Scanner light and Arduino as an RGB lamp Dot Matrix Printer from a CD/DVD Reader with Arduino 
Add instructable to: