Scanner Light and Arduino As an RGB Lamp




About: A eletrical engeneering student, video games lover and hardware aficionado. Starting my journey through the world of electronics. Microcontrollers?! I love them!

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....

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: 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.

Make it Glow!

Participated in the
Make it Glow!

2 People Made This Project!


  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

26 Discussions


4 years ago on Introduction

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 :)

4 replies

Reply 4 years ago on Introduction

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.


Reply 4 years ago on Introduction

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.

leds with transistors.png

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.

From Step 1: "..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."

How did you determine this exactly?

Wawoo wawoo 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.

1 reply

4 years ago on Step 2

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?

From the ather hand, the "prepared" sensor turns outside of the scanner/copier chassis, well this point may compensate possible overheating in a constant light source' mode...

1 reply
Robson Coutoschabanow

Reply 4 years ago on Introduction

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.

Anyway, this sensor would be on trash if I not had taken it, it i had burned it, at least I would learn something.


4 years ago on Introduction

Nice project.

I also wanted to reuse the LED strip from a scanner.

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.

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).

I broke the first one I attempted, second one was easier.

Scanner LED.jpg
1 reply

Thanks for the tip!

I did not mention that i separate the pcb from the plastic housing, now i fixed that, thank you.

What will you do with your LED strip?


4 years ago on Introduction

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!

1 reply