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 ads by
Signing UpStep 1Get Stuff
- 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)
- soldering iron
- glue gun
- x-acto knife
- tape
- white glue
- paint brush
- imagination
| « Previous Step | Download PDFView All Steps | Next Step » |
















































hope this helps
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?
would it be okay to use one resistor on the anode?
"moodlamp does not name a type
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.
it gives another error "pulse not defined in the scope" for the statement pulse whit
e
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.
//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.
"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.
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.
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!!
I'll see if I can't build a chameleon lamp myself, and post my result here. Wish me luck!
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.
definately worth 5 stars
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.
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.
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.
One of the smartest led color "change" application ever seen, I'll made one for sure. Great !