USB Chameleon Lamp ( Color replicating )

Another awesome way to use Your Own Color Sensor is a "Color Sensing and Replicating Lamp" or simply a Chameleon lamp. The chameleon lamp is a super-easy-to-build project which can be used as a night light or just as a decorative piece.

This lamp features :

1. A Custom Color Sensor

2. Personalized diffusers ( this one uses a cube shaped diffuser )

3. Different operating modes ( color sensing - color cycling ( mood lamp ) - random combinations )

4. Responds to knock

4. USB compatible.

5. Fully programmable and customizable.

6. Auto-calibration and RGB individual intensity adjustment.

Step 1:

USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )

To make this you'll need :

1. An arduino Uno ( or any other variant )

2. A color sensor - (Make Your Own !)

3. A copper clad - single sided board

4. Supplies for PCB fabrication - ( laser printer , glossy paper, FeCl3, HackSaw ,etc.)

5. Cardboard to make the case or a 3D printed case


Components :

1. 6 x 10K potentiometers

2. 3 x BD139 NPN power transistors ( or equivalent )

3. a strip of Female headers, male headers and male right-angled headers

4. Some ribbon cables and relimate connectors ( 4pin , 3pin )

5. A high intensity RGB LED

6. A piezo disc

7. 4 x 1M resistors

8. CD4051 8 bit multiplexer


Hardware :

1. A piece of cardboard

2. A bottle of superglue

3. Paper sheet ( white / ivory )

4. Black insulating / electrical tape

5. Heat shrink tubing ( 12mm , 4mm , 8mm )

6. Black paint

7. Soldering iron and solder

Step 2: Make the "Heart"

USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )

The "Heart" of the Lamp is the Shield - ( TriSense Shield ) which is mounted on an Arduino Uno.

The shield is compatible with all the versions of Arduino boards. Start making the shield by printing the layout ( given below ). Print it on a glossy paper and make your board using the toner transfer method.

You'll find detailed instruction guide @ Here. This previous instructable covers all the hazards and safety warnings associated with PCB manufacturing.

After you've etched the board and drilled it, start soldering the headers and then the IC base.

Now you can start soldering the other components. Solder the BD139s at the end.

Description :

The Shield basically consists of :
1. A 7 pin connector to connect the 6 pin / 7 pin Color sensor.

2. An 8 - bit multiplexer , this helps us to reduce the number of PWM pins required by the Sensor. It does so by multiplexing only one PWM pin to drive the three RGB leds on three different values.

3. An on-board LED driver + Hue calibration circuit. It also supports external power input if the project requires a bunch of extra high power LED .

4. Extra headers to attach some extra inputs/ outputs if needed.

5. A ShiftLCD jack for upcoming enhanced versions of this Lamp.

These features enables us to modify and program it in endless ways.

Your shield is ready !

USB Chameleon Lamp ( Color replicating )
TriSense Shield.brd87 KB

Step 3: Knock input sensor

USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )

The Lamp uses a "Piezoelectric" disc as a button. The lamp reacts when it is knocked. This uses the default "Knock sensor" code.

It works on the principle of piezoelectricity, when the piezo element is pressed or knocked, the compression of different layers of the piezo disc generates considerable amount of voltage. This voltage is sensed by the analog 2 pin on the arduino. Whenever we knock the sensor, if the voltage is above the set threshold , it tells the Lamp to react accordingly.The input is then pulled down by using 4M ohm resistor network.

Solder the negative terminal of the piezo element to the ground pin on the Shield. Then solder the other pin to analog A2. Now finally solder the 4M resistor network as shown.

The graph in processing shows the voltage spikes when the sensor is pressed or knocked.

You've successfully made the knock input.

Step 4: Make the Diffuser and the Case

USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )

Diffuser :

Cut a white sheet of white paper in according to the given layout.

Fold the flaps and glue them to create a cube. Cut one of the edge to make space for the RGB LED.

Add black electric tape on the edges ( it looks good ).

Case :

Take a piece of cardboard and cut it according to the given template (If you're not using a 3D printed case). The dimensions depends on the features that you want in it. This version uses a 10.5 cm X 10 cm X 5.5 cm cardboard casing.

Fold the shaded flaps and glue the box using superglue. Paint it black and add black electrical tape to smooth out any imperfections or shabby edges.

Step 5: RGB LED and Hue Fine-Adjustment Board

USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
Show All 11 Items

Board :

The RGB Hue fine adjustment board is the most important element of the Lamp. Though the lamp has been programmed to auto-calibrate the sensor, the R G B individual LEDs in a single LED draw different amount of current and at the same output voltage, each LED differs in the intensity.

To make this , follow the schematic and start by soldering 3 x 10K potentiometers on a perf-board.

Solder a 4 wire relimate connector to the board ( keep the polarity in mind ).

RGB LED :

Solder a RGB LED on a perf-board and solder 4 pin header to it.

Cut a strip of paper and fold it to form a triangular prism so that it fits in the hole of the diffuser.

Paste the structure on the LED so that it fits snugly in the diffuser.

Step 6: The Sensor

USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )

You'll find a guide to make your own sensor Here!

After you've made the sensor, Place a 4-6 mm heat shrink tube piece over the LDR.

Now add a 12 mm heat shrink tube over the whole sensor as shown.

Secure the connections either by hot glue or by superglue and slide a piece of Heat shrink tube over the cable.

The heat shrink tube needs to be black. Any other color of heat shrink tube would give false readings.

Your sensor is ready !

Step 7: Fix the Components

USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
Show All 7 Items

After you've created the case, fix the Arduino to the base using screws.

Place the shield over it and attach :

1. Color Sensor

2. RGB control Board

Now cut a small piece in the base to accommodate the shaded sensor.

Superglue the RGB control board to the edge of the case.

Finally cut a hole in the lid to fix the LED.

Step 8: Final touches

USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )
USB Chameleon Lamp ( Color replicating )

To complete the body , glue the diffuser on the LED. Place the Knock sensor on the exterior of the case and secure it with black electrical tape.

Add tags and decorate as you like.

Look for any imperfections and shabby edges and fix them using some electrical tape.

Step 9: The TriSense Library

The TriSense RGB library is a custom made library created by me to make it easy to program the Lamp.

Instructions to install the library

1. Download the TriSense.rar archive

2. Extract the TriSense folder in C:\Program Files (x86)\Arduino\libraries\TriSense

3. Restart the IDE and check whether the library works ( using the CycleRGB example )

Functions :

The library mainly consists of these operations :

1. TS_RGB ( int red pin, int green pin, int blue pin);


2. CalibSeq ( mode ) : this function calibrates the sensor, it sets the white balance and needs to be invoked only once.

in the "mode" space , if you want serial monitor for debugging ,

write : CalibSeq("Debug");

else : CalibSeq("XDebug"); it won't initialize the Serial monitor.


3. GetColor( int delay ) : this function reads the color of any object which is placed under the sensor.

the optimum value of delay is 50 ms. Reducing the delay would give false readings and increasing the delay would slow the response.


4. CycleRGB( int delay , float brightness , float saturation ) :

this function cycles RGB colors sequentially ( mood lamp effect )

increasing the delay would slow down the animation.

the value of brightness and saturation varies from 0 to 1.


5. SetHue ( int red , int green , int blue )

this function is used to directly control the RGB led by providing it with values for each color ranging from 0 to 255.

USB Chameleon Lamp ( Color replicating )
TriSense.rar8 KB

Step 10: Programming

The full program is quite large and it took me several days to create the library and get it to work.

/* This Code is written by http://www.instructables.com/member/electro18/ The project can be found on the same page */ #include TS_RGB ts(11,10,9); int S_Tap, dTap_stat, sTap_stat , val, first, second, last_doubletap, last_tap; int restate = 0, tap, doubletap; long idle, returnst, time; int dly=100, prevkno=0, knocks, last_knock, knock_stat, state,mode, MaxModes=4, calib_st; void setup() { Serial.begin(9600); // ONLY FOR DEBUGGING ts.SetHue(255,0,0); // RED INDICATES THAT SENSOR IS NOT CALIBRATED ts.CalibSeq("Debug"); // WHITE BALANCE CALIBRATION OF SENSOR IN DEBUG MODE for(int i = 0 ; i finish && val > finish) { if(millis()-idle > dly) { val--; idle=millis(); } analogWrite(9,val); } if(val==finish) return 1; else return 0; } int knock(int thr) // Knock function { int kno = map(analogRead(2),0,thr,0,1); kno = constrain(kno,0,1); if(prevkno!=kno && millis()-time>50) { knocks++; prevkno = kno; time = millis(); } return knocks/2; } void sleep() // Sleep function { if(returnst==0) first = PwM(1,10,150); if(first == 1) returnst=1; if(returnst==1) second=PwM(4,150,10); if(second == 1) returnst=0; }

The fact that I haven't used delay() function in this program makes it so lengthy. If we use delay() function, the program stops for that particular time period this means that all the inputs , outputs and other calculations would stop working. This would create a big problem while using knock input.

I got the CycleRGB without delay program from : http://mcviruss.nl/arduino/rgb_rainbow_v2.pde

USB Chameleon Lamp ( Color replicating )
Project_Hue_Program.ino3 KB

Step 11: Understanding the program

The program first initializes White Balance calibration sequence for the color sensor. After the sensor is calibrated, it puts the lamp in sleep mode ( marked by slow Blue PWM fading ).

The lamp continues to take readings from the knock sensor.

As the user taps the sensor twice within a second , the program counts it as a double tap. It changes the mode to ColorCycling mode. If the user taps it again ( once ) , the animation speeds up.

If the program senses another double tap , it changes the mode to color sensing mode.

Step 12: Operation and Troubleshooting

USB Chameleon Lamp ( Color replicating )

Download and print the given color wheel to test and calibrate the Lamp.

Operation :

1. Before powering-up the lamp, place a perfect white - non glossy surface under the sensor.

2. Now turn it on , The lamp should now start the calibration sequence.

3. As the lamp calibrates the sensor, the Lamp would glow bright red.

4. Once it has been successfully calibrated, it will flash green and then get into sleep mode.

5. Knock it twice to activate the RGB cycling code.

6. Go on tapping it till the animation speeds up.

7. Or just double tap it to run the color sensing code.

8. In the Color Sensing mode, the sensor will continuously take readings from the object and replicate the color.

9. Now just place it on any object and watch it adapt to the color.

10. Tap it once more to lock the color that you like !

Troubleshooting :

1. Check the connections thoroughly.

2. Damaged transistors or shorts may affect the brightness of the RGB led.

3. While calibrating , glossy surfaces may give false readings.

4. Piezo sensor should have a rigid support to increase it's sensitivity.

5. The sensor should be capped to avoid false readings due to ambient light.

Debugging :

1. To check the values of the sensors , you can change the mode to debugging mode.

2. This will allow you to monitor all the readings using serial monitor.

Step 13: Conclusion

The lamp is now ready to add Hue to the ambiance, it also demonstrates how simple and basic components could be connected to create something unique and fascinating.

Being open-source and programmable , the lamp offers infinite possible ways of customizations.

I'm planning to make a v2.0 Hue Lamp with an LCD and many other functions.

Thanks for reading ! Feel free to comment and ask if anything appears to be unclear.

And if you find this project interesting, please leave a vote :)

 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel