loading

There are a lot of ways that you can activate an electronic lock. You can use passwords, radio signals, or even voice commands. In this project, I am going to show you how to make a lock box that opens and closes based on color recognition.

With a color recognition lock, anything can be a key. You can set the lock to recognize the color of a cereal box, or the cover of your favorite book. You could even use pictures on your phone as the key. With so many different color combinations, a color lock is also very difficult to break into.

Step 1: Watch the Video

Here is a video walkthrough of the project.

<p>Hi! I'm trying out your project but I am stuck on the part where I set up the lock. The values are all similar. Do I use the color differences as the values to set the lock?</p>
<p>You will need to calibrate it for the lighting in your room. If there's too much light, it can saturate the sensor and cause problems.</p>
<p>hi sir plss help me. how to make the sensor only recognize your desired color .. it all opens in all colors RGB How to know 1 color ?</p>
<p>You are probably getting too much light from the room to the sensor and it is saturating the output.</p>
<p>Thanks, I will try that. Once I calibrate it, I should use the Green-Red Difference value and the Green-Blue Difference value to set the lock, Correct?</p>
<p>Yes. You need to use the differences.</p>
<p>hi sir can you plss help me im done making it but how it works ? </p>
Could you be more specific in your question?<br />
<p>Hey! Great project. I am planning to build this one in the future. My only worries are regarding the fotoresistor value. How should I calculate the value of the resistor in series with the photoresistor? Is there a certain output voltage necessary between the two resistors? Which value of the fotoresistor did you use?</p><p>Thankyou very much in advance for clarifying!</p>
The biggest problem with photo resistors is that they aren't standardized and you can't buy specific values. It is kind of random. So you need to do a little trial and error.
<p>Oh, OK, I will see what I can do.</p>
it works<br>but whenever I connect it first opens the lock then after 2 ~3 seconds of locked
<p>That is strange. I am not sure why it is doing that.</p>
it's not working<br>I am using 100k resister in place of 10k<br>and <br>my ldr is comparatively smaller than yours
<p>Post a picture of your circuit so that I can see how everything is connected</p>
<p>Note that different servos have different color coding schemes for their wires.</p><p>Futaba http://www.fatlion.com/sailplanes/images/futabaconnector.png</p><p>Hitec http://www.fatlion.com/sailplanes/images/hitecconnector.gif</p><p>JR http://www.fatlion.com/sailplanes/images/jrconnector.gif</p><p>Airtronics http://www.fatlion.com/sailplanes/images/airtronicsconnector.gif</p>
<p>tks just saved me =)</p>
pls help
how it works
<p>Read through the tutorial. If you have any specific questions, feel free to leave a comment and ask.</p>
Cool. Would you be okay if me and my friend used a slightly modified version of this in a science fair? How should we put you for credit? Is just a link to this page fine, or would you like your name?
<p>Feel free to use anything that you like. I don't particularly care about credit. If your science fair requires references, just provide a link to the page. </p>
Great project!<br>I liked! <br><br>I can use a strong steel to lock the box! And make a a safe box to put a valuables.<br><br>Very nice! <br>And the idea's comming...<br><br><br>&quot;Unfortunately I had a bad experience when I was editing my instructable since the app, and was erased your comment by this cause (It's a bug! I think). I'm very sad for this!&quot;
<p>I'm Hatoru. I am very interesting with project color recognition lock. But I want it more secure. I want to build two eyes color recognition..... but I have a problem with the code. Could you help me ? Thks</p>
Sorry. That does sound interesting .But at the moment, I am extremely busy and am not able to take on any new projects. Good luck.
<p>I made this.... It was awesome and could u please explain how the code works?</p><p>Again thanx for the awesome lesson....</p>
The Arduino turns on the different color LED one at a time. While each color is on, the arduino measures the about of light that is reflected off the surface using the photoresistor. The Arduino then compares the measured values for each color to the set lock values in the code. To help adjust for changing light in the room, it uses the difference between the colors rather than the absolute values. If the measured values fall within the set sensitivity tolerance, then the Arduino activates the servo and unlocks the box.
<p>Yeah! I got it.... but i placed one object in front of the colour sensor and watched the values of the arduino serial monitor..... I got different values for the same object, same room, same background lightning and the same place... here I'll paste some of them...</p><p>Green 194</p><p>Red 340</p><p>Blue 312</p><p>Green-Red Difference -146</p><p>Green-Blue Difference -118</p><p>Lock</p><p>****************************************************</p><p>Green 292</p><p>Red 277</p><p>Blue 306</p><p>Green-Red Difference 15</p><p>Green-Blue Difference -14</p><p>Lock</p><p>*****************************************************</p><p>Green 633</p><p>Red 340</p><p>Blue 211</p><p>Green-Red Difference 293</p><p>Green-Blue Difference 422</p><p>Lock </p><p>******************************************</p><p>This is my problem........ plz help me!</p>
<p>helloo......I made this colour recognition lock...and.....the problem is......it opens for any colour........Can anyone help me to make the lock recognize only one colour..???</p>
Try adjusting the sensitivity variable in the code.
Very much thanxx for the help.......It's working fine now.......can you send me the code to recognize blue colour....PLZZZZ... ;) ...
<p>It all depends on the LED that you are using, the light sensor that you are using and the ambient lighting in the room. You just have to use the serial monitor tool in the arduino software to see what values it senses when you hold the blue color up to it. Then change the values of the &quot;GreenRedLock Code&quot; and the &quot;GreenBlueLockCode&quot; in the code to match.</p>
<p>helloo......I made this colour recognition lock...and.....the problem is......it opens for any colour........Can anyone help me to make the lock recognize only one colour..???</p>
<p>helloo......I made this colour recognition lock...and.....the problem is......it opens for any colour........Can anyone help me to make the lock recognize only one colour..???</p>
<p>I made it ! just nice and easy. I will try to adapted in a geocaching project in the next future. Thank you.</p>
<p>Love geocaching, would be a cool cache of some sort.</p>
how about making it open a door lock..what mods for that?
Just mount it to a door or next to a door. Then hook up an electronic door lock and that should work.<br>
<p>Great writeup! </p><p>However i am still in a pickle with color detection as i am using a FPGA (no analog i/o) and using a ADC would be no simpler than a color to frequency chip :/ </p>
<p>What an amazingly Brilliant Idea ! :) </p><p>Thanks for sharing. Love all of your DIY Hacks and How To Tutorials. </p><p>Voted ! :) </p><p>Warm regards,</p><p>Akshay.</p>
I would think that you could measure resistance value of the voltage divider with the leds turned off when you initialize the arduino and set it as a reference so that it will completely (or nearly so anyway) ignore the ambient light altogether.
<p>cool idea</p>
<p>cool idea</p>
<p>cool idea</p>
<p>cool idea</p>
<p>This is brilliant!</p>

About This Instructable

33,273views

470favorites

License:

Bio: My name is Jason Poel Smith I am a Community Manager here at Instructables. In my free time, I am an Inventor, Maker, Hacker, Tinker ... More »
More by DIY Hacks and How Tos:How to Make a Festivus Pole Add Wings to an Infant's Halloween Costume Bubble Bath That Never Runs Out Of Bubbles 
Add instructable to: