Main Menu

Secondary Menu

RGB Distance Dependant Light

Introduction: RGB Distance Dependant Light

You are probably thinking: "RGB Distance dependant light", what is that? Let me explain the idea to you. For a school project I was required to make a smart object, so I decided to combine a lamp with an ultrasonic sensor. The entire project is powered by an arduino UNO R3.

The machines and tools you will need:

Laser cutter (minimal size 290x174 mm)

A drill with a 5mm bit (used to drill out the holes to fit the LED's)

Possibly a exacto knife (might come in handy if your cut pieces that haven't been cut all the way through)

Screwdriver according to your screw heads

Optionally a hecksaw

The products you will need:

Arduino UNO R3

3mm Plywood

3x rgb led

3x 220 ohm resistor

1x ultrasonic ping sensor (The model I used was a HC-SR04)

4x M4 nuts and bolts

Step 1: Making the Casing

The casing is designed to snugly fit all the components I used. To make this casing i used 3mm plywood and cut the panels to size using a laser cutter. The slot you see in the top panel should have been used to insert a acrilic panel, but due to time and difficulty constraints I unfortunately wasn't able to finish that part.

The model is designed to be used with a external power adapter for the arduino. The front two holes are used for the "eyes" of the ultrasonic sensor. I designed them to be a snug fit.

The minimal size of the laser cutter you'll need to print out the included case as is, would be 290 x 174 mm

For the led's there are three long sided pieces on the bottom right. These are designed to snugly fit internally as a platform for the led's to rest in. When you hav cut the panels and removed them form the wood, you sould drill two additional holes in the bottom of the tray. This hole should be snug to fit the led's in. In my case this was solved by using a 5 mm drill bit.

Attachments

Step 2: Making the Electronics

For the electronics i used 2 RGB LED's with 3 220 ohm resistors. The led's are soldered in a parallel setup as shown in the included diagram. I chose to solder wires directly to the header of the ultrasonic sensor. To attach wires in a arduino I used some male headers and soldered all the leads to the correct terminals: The pins area soldered as followed; The trig is soldered to pin 13, the echo to pin 12, the red annode to 11, the green annode to 10 and the blue annode to 9.

Step 3: Progamming

The way I went about programming this device was quite a journey. I wanted the led's to react on the ultrasonic sensor and change color according to the distance the ultrasonic sensor returned. When the distance between object and sensor is low, so the object is close, the color is red. The further away the object goes, the greener the color gets. Evrithing in between is a mix of those colors and scales up as the distance increases. This results in a color spectrum between red and green.

Upload the code to the arduino cause you wont have acces to the usb port once the arduino is inserted in the casing.

Attachments

Step 4: Assembly

You sould combine and glue the two pieces of the casing seperately, there area t shaped holes that have to be faced upwards so the bolts an nuts can be inserted later. The top is now ready for the led insertion. Put the led's in the therefore drilled holes. Up next i started the total assembly by putting the power lead through the hole and connecting it to the arduino, caus this would be a lot harder to do later in the process. Up next I lowered the arduino in place and slided the ultrasonic sensor in its designated place. Then it was time to close the lid, cerfully put the lid on and secure it using the nuts and bolts on the top side.

Then it's just a matter of connecting the power plug to the wall outlet and voila, your creation should be lighting up and according to the distance sould be changing color.

Epilog Challenge 9

First Time Author Contest 2018

Paper Contest 2018

Tips

Questions

6 Comments

Bryan:Thanks for looking into this for me. I don't have a windows machine I can run Arduino on, so wasn't able to try that. Guess it's good to know there are some differences between the two IDE applications depending on which OS you are on. Great project! I was mainly interested in the HSV to RGB conversion. I went to the references you had and adopted it to my needs. Also realized I have common anode RGB LEDs and your circuit uses common cathode LEDs, so I got the compliment colors when I final got things running, so had to make modifications for that as well. Again thanks for your help.

Hi rspratt,That's a strange thing to occur.Would you like to answer a few questions for me to be able to possibly recreate the problem for you.- What OS do you use?- Have you copied and pasted the code from the instructables page ofr dud you download the .ino file?

Bryan:Thanks for the response. I used the downloaded .ino file as when I copy and paste the text from the instructable I get lots of errors due to the way the intractable formats the text. I'm running Arduino IDE version 1.6.7 on the Mac OS. I did some experimentation and found that if I remove the parameters from the HSBToRGB function both in the call and the function itself and then replaced all the variables in the function with those declared at the top of the code it would compile without errors. looks like there is something with how the parameters are passed between the call and the function.

rspratt, The code I worte was on windows, I recently made another private project and the code would compile and run fine on osx, but wouldn't run on windows unfortunately. I beleive there is somewhat of a mismatch between osx and wiindows, even if the .ino file is the same. Haven't found any solution to this problem though.

Newsletter

Let your inbox help you discover our best projects, classes, and contests. Instructables will help you learn how to make anything!