Instructables
Picture of Magical Colour Copying Chameleon Lamp
DSC02492.JPG
In this Instructable, I will show you how to make an Arduino powered lamp that detects the colour under it and then attempts to emulate that colour. All using easy to find parts (most can be found in the Dollar store with the exception of the Arduino of course).

It turns out that a colour detection module can be built for next to nothing, and the results are astoundingly good for the investment.
The biggest hurtle in this project is getting the balance right on our sensor as we are using LEDs to represent the colour being detected, which becomes our limit. Dark colours are more difficult to represent. The sensor still does a good job at detecting and giving a reliable reading, but again, balancing becomes the real issue. Reflectivity will also play with the readings. That being said, this sensor would work great for all manner of colour detecting projects. Best of all it is super cheap to make. 

I really hope that a few of you out there both copy and improve on my lamp, or find some other great uses for this cheap, easy to make, Arduino friendly Colour sensor.
 
Remove these adsRemove these ads by Signing Up

Step 1: Get Stuff

To build the colour detection module you will need
  • a CdS photocell (cadmium sulfide), also called an LDR or light dependent resistor. Anyways, it is one of those little light detectors on most garden lamps, night-lights, etc.
  • A 10K resistor
  • A  red LED
  • a green LED
  • a blue LED
  • alternatively you could use an RGB(red green blue) LED
  • A 220 ohm resitor
  • a bit of shrink wrap or a cut section of a pen or anything else that would be a decent shroud for the LDR
  • a shroud for the entire sensor (film case cut, pvc pipe, bits of plastic, again anything to shield the whole ensemble from ambient light a bit)
  • a bit of prototyping board.
  • Hookup wire (I also use male header pins and jumpers, but this is not required)

To make the rest of the lamp, you will also need.
  • An enclosure
  • a diffuser (I managed to get mine all in one with a tomato container from the Dollar store)
  • an Arduino that will fit in your enclosure (I used a mini)
  • another RGB LED or a red, green and blue LED
  • three 220 ohm resistors
  • some decor (use your imagination here, I went for the magic lamp look, you do what pleases you or go with what you have on hand as I did)
Tools that you will need
  • soldering iron
  • glue gun
  • x-acto knife
  • tape
  • white glue
  • paint brush
  • imagination
I decided to leave mine tethered to my computer for power, but you may want to add an on/off switch, and batteries.
1-40 of 48Next »
VladimirM1 month ago

This is coolest applied-color-theory
I've ever seen.

Kudos to you sir, this good work! :)

e27480281 year ago
i am not able to calibrate the sensor. please help!
mooner772 years ago
could you guys please help me make a diagram for a RGB LED.
fjordcarver (author)  mooner772 years ago
http://www.instructables.com/id/Using-an-RGB-LED-to-Detect-Colours/

hope this helps
lioncour2 years ago
Hi. I got some trouble.

I put the .ccp and .h files in libreary/moodlamp.
I got no skteches folder.
Using IDE 0022

when i try to compile the library i get this error.


sketch_feb23a.cpp:1:22: error: moodlamp.h: No such file or directory

Any idea what i am doing wrong?
aemery12 years ago
How would you do this using a common anode rgb.
would it be okay to use one resistor on the anode?
fjordcarver (author)  aemery12 years ago
no, you would use one resistor on each cathode, and your code would be different as well. The leds will light when pins go low as opposed to high.
robot13982 years ago
i am getting errors compiling the code
fjordcarver (author)  robot13982 years ago
Could you be more specific?
fjordcarver (author)  fjordcarver2 years ago
what does the error say?
it says
"moodlamp does not name a type
fjordcarver (author)  robot13982 years ago
Sounds like you don't have the library or a typo in your code. Did you install the library?
how do i do that??
fjordcarver (author)  robot13982 years ago
From step 6 - For the emulation lamp I am using my custom Moodlamp library, you can get the library files and documentation on my other RGB Instructable, RGB Moodlamp with Custom Library. Otherwise you can just copy the colour sensor handling code and output to your RGB lamp in your preferred manner.
the information that you want is on step 3.
If you are using Arduino 1.0, there is a potential issue with the library which I will address soon(a little busy with Holiday celebrations still). See the post in the comments here for some additional info.
downloaded the libarary successfully
it gives another error "pulse not defined in the scope" for the statement pulse whit
e
fjordcarver (author)  robot13982 years ago
could you show me the code as you have it in your sketch? it sounds as if you have a comment uncommented
meaning one of the lines of comment text is on a new line. putting a // in front of the text that is not code is important. either backspace the line feed that has been inadvertantly added, or add // in front of comment text that is on its own line.
(removed by author or community request)
fjordcarver (author)  robot13982 years ago
As I already replied. You have left a comment uncommented. Just putt // in front of the line that is a comment and not code that reads" pulse white".
fjordcarver (author)  fjordcarver2 years ago
like this
//pulse white
would it be too much to ask that you remove the over zealous post (the one above where you have posted the entire sketch)? It sure takes up a lot of room for something that could have been posted with a single line. I don't think anyone needs the sketch with a typo in it. It is already included in the instructable.Thanks.
removed
foamyguy2 years ago
If you get an error message that says something about

"WProgram.h not found"

This seems to be a bug with the Arduino 1.0 IDE. Switch back to 22 or 23 and it should compile and run fine.
fjordcarver (author)  foamyguy2 years ago
Would this error be when compiling the moodlamp library? I have not seen that, but thanks for the tip.
Im not really familiar with the Arduino IDE and programming with it yet. So I don't know for sure what part of the process caused it. But here is what happened:
1. create libraries folder in my sketch book folder
2. create Moodlamp folder inside libraries
3. paste the .cpp and .h files into Moodlamp folder (you should consider attaching these files to this instructable too. I eventually found them on the other one that you link to, but it threw me off for a while.)
4. paste the code into arduino IDE
5. press the upload button - at this point there was an error that said something about WProgram.h not found.

When I switch to IDE 0022 and repeat these steps everything works as expected.
fjordcarver (author)  foamyguy2 years ago
I think if you comment out the #include at the top of the .cpp file, it may work in 1.0...maybe, let me know if you try
fjordcarver (author)  foamyguy2 years ago
Thank you for the awesome feedback. I have not had this error, so I looked it up, it appears that after 1.0 the filename WProgram.h was changed. Your work around appears to be the best method at a glance so thank you for sharing. I have not had the time to delve deeper, but will certainly look and will update the step to reflect your solution as well.
I also appreciate you pointing out that I should include the files, I will fix that later as well. I am a newer author here, and really appreciate knowing what people want/expect.
If you got everything working I'd love to have a picture posted, it'd be my first.

I sent you a private message.;) Thanks for being Awesome!!
LexanPanda2 years ago
This is a great instructable, and really well done! Am I correct in assuming you got the idea from ThinkGeek's Huey? :)
fjordcarver (author)  LexanPanda2 years ago
Actually no,(believe it or not) but I found out about Huey while I was finishing it up. I was bummed, but I googled Chameleon Lamp to make sure it was the only one (nothing ever is) and found Huey. Huey is cuter, but mine is better. Lol. Actually I like that Huey writes to his eeprom to store his balance scan, I should have done that too. Then you only set the lamp one time. I need to set mine every time I turn it on.
Yep, custom made is always better than store-bought(and usually cheaper, too). How hard do you think it would be to update your code to store balancing data?

I'll see if I can't build a chameleon lamp myself, and post my result here. Wish me luck!
fjordcarver (author)  LexanPanda2 years ago
It would not be too hard, a couple of lines, but I probably won't get around too it. For myself, the thrill of seeing an idea work is all that I am after. I will leave the better version for the next person to build.
If you like. build yours, post it, and I will help you (if you need it) to add the functionality to yours. All you would need to do is write the array to eeprom when you take it and add a bit of code to the checkBalance function to verify if the eeprom is storing any value. You could also just check if it is there in setup.
janw2 years ago
Great project. I will definately try to buid such a colorsensor.

definately worth 5 stars
fjordcarver (author)  janw2 years ago
Thanks!! Post a picture if you do!
You have some very cool projects and I'm jealous because I'm in the same contests. Great Job. I'm going to have to build one of these.
fjordcarver (author)  matt.e.jenkins2 years ago
Thanks, quite the compliment. You could always vote for me.
Your projects are awesome too.
I just wrote a new one detailing just the sensor aspect on a breadboard, I included Processing code that lets you see what colour the sensor sees, it might be of interest to you. 
Hey, in that picture I can see you wrote digital and analog can you explain how this system work of this chameleon lamp works, please!!!
fjordcarver (author)  adar12 years ago
I am not sure what it is that you are missing. Sometimes it is difficult to understand what somebody is having trouble with, so try and be as clear as possible in your questions.
Digital and Analog pins correspond to pins on the Arduino. The Arduino is a microcontroller and is doing the 'Thinking'.
Most sensors have outputs that in turn connect to inputs somewhere when in use. In this case I am connecting the sensor to an Arduino which in turn is interpreting the data it is recieving. (The output connects to an analog pin as it is outputting an analog voltage)
The LEDs are connected to pins on the Arduino as well, digital pins, which in this case (see the code) are setup as outputs. This allows you to turn the lights on and off.
This information is all in the Instructable, so please try reading it again.
adar12 years ago
Hey, can you give me more technical details on how the circuit and the system works of the chameleon lamp!!! I think you you made a cool lamp and I am going to try this out!!!! thanks you!!!!
fjordcarver (author)  adar12 years ago
Thanks for the compliment
Step 2, has the details on how it works, Steps 3 and 4 detail the circuit, and the code is on step 6. You will have to be more specific as I am not sure what information you are missing.
If you would like to see the sensor simplified and taken out of the lamp you can read my other Instructable, Using an RGB LED to Detect Colours.
Thanks!!!!
amaze12 years ago
Very COOL !!!
One of the smartest led color "change" application ever seen, I'll made one for sure. Great !
fjordcarver (author)  amaze12 years ago
Thanks so much! Be sure to post a picture when you finish!
1-40 of 48Next »