0% found this document useful (0 votes)
16 views

Arduino Combination Lock Lockduino

This document describes how to build an Arduino combination lock called Lockduino. It uses an Arduino, servo motor, LEDs, potentiometers, and other basic electronics components. The 10 step guide provides detailed instructions on assembling the circuit board, connecting the components, programming the Arduino, and constructing the enclosure.

Uploaded by

laik.punto.ar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Arduino Combination Lock Lockduino

This document describes how to build an Arduino combination lock called Lockduino. It uses an Arduino, servo motor, LEDs, potentiometers, and other basic electronics components. The 10 step guide provides detailed instructions on assembling the circuit board, connecting the components, programming the Arduino, and constructing the enclosure.

Uploaded by

laik.punto.ar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Food Living Outside Play Technology Workshop

Arduino Combination Lock: Lockduino


by electricloser on March 14, 2013

Table of Contents

Arduino Combination Lock: Lockduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Arduino Combination Lock: Lockduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: Ingredients: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2: Prepping the Perf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 3: Ribbon Cable Dissection & Soldering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 4: Arduino Backpack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 5: Making the Front Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Step 6: Making the Servo Holder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Step 7: Final Pictures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Step 8: Breaking Down the Arduino Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Step 9: Final Arduino Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Step 10: Conclusion: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Author:electricloser
I enjoy learning about electronics. I am self-taught. I finished my Electronics for Dummies and The Complete Idiot's Guide to Electronics! I moved on to
Semiconductor, NJATC. Now, I am trying to learn C language for my Arduino!

Intro: Arduino Combination Lock: Lockduino


Ready to put a combination lock on your door to keep out intruders? You've come to the right place! In this i'ble I will show you step by step how to make a combination
lock for your door!

Watch this video of the finished product!

What did you make?


Lockduino ! It's a lock that is controlled by 4 potentiometers. It may also be controlled by IR in the future :?
I just used some perf board, ribbon cable and basic electronics to make it. I got so mad with the perf board (my dremel is very tiny and doesn't cut well) so I brandished
my oscillating saw and zzzzzzzip! Whoops! Maybe next time I should be a little more careful ;-).
How did you make it?
Tell us how you got the idea for the project.
We were staying a rental cabin in the mountains for the weekend and I was utterly enthralled by the electronic keypad that you typed in your cabin code to get it. You
type in the code and heard, "WRRAANT" and the door popped open. So I decided to make one; modified. Hence I present to you: Lockduino!
Did you work with anyone else?
Nope. Just me!
Did your plan and ideas change as you worked on the project?
No, not really. I pretty much stuck the same plan the whole time.
Where did you make it?
I made it all in my room on my electronics work table and downstairs by our computer (for programming Arduino). A lot of running up and down the stairs!
How did the project connect to other activities in your life?
Well, it keeps out my friends when I don't want them in my room, it keeps my stash of equipment safe and sound!
What did you learn?
What I learned was how to properly use if statements with Arduino. It took some time but I got the hang of it. You can see this thread to see how I was in
misunderstanding about how to construct my if statements!

Image Notes
1. The inside of the door.

Step 1: Ingredients:
Electronics:

Arduino
1 Micro servo
1 Green LED
1 Red LED
2x 350 ohm reistors
4x 10k (or 50k) micro potentiometers (the higher the resistance the better)
Perf board
2.54 cm. pin headers
Insulated jumper wire
Heat shrink
Ribbon Cable
9v battery and clip
4 AAA battery holder

Tools:

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Soldering pencil
Tool to cut perf board (I found that the oscillating saw works the best!)
Razor blade
Wire cutters
Wire strippers
Needle-nose pliers
Electrical tape
Helping hands are helpful!
Hot glue gun
Heat gun
Sharpie
Paper and pencil
Drill with 1/4 bit, and 3/8 bit.

Parts:

Insulated ring terminal


Basswood or 1/4 ply
Double-sided tape

Step 2: Prepping the Perf


How many times have I said prepping the perf?
Anyways we're going to get started my drawing out a little template for the 2 LEDs (or one if you have RGB LED) and for the pots. I spaced the pots about 1 1/2 inches
apart. Just keep in mind that you have to leave enough room for your turning knob. Cut out your template and solder all the components to it.
To connect all the potentiometers; begin by making a jumper like the one shown in picture 7. You don't have to do this, you could just use a insulated wire like I did with
the positives. All the negatives (left side) connect together. Connect all the positives (right side).
Now, VERY IMPORTANT! TEST! You don't want to finish the project and then go, OH NO, it's not working!!!
To test, hook up the red wire (from the perf board) to 5v on Arduino and the black to GND. Connect your multimeter's black test lead to GND. Connect the red wire (of the
multimeter) to the middle pin of the pots. Turning the pot should give you a read of 0 volts through 5 volts.
EVEN MORE IMPORTANT!
Make sure that when you solder the pots on they are all level and the same height. Otherwise, you will have horrible problems when it comes to adding the knobs.

Image Notes Image Notes


1. This is for the LEDs. If you have and RGB LED, then just draw one of these 1. All cut! Notice I cut on the outside of my lines.
in the very center.

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes Image Notes
1. Everything in place! 1. All soldered
2. Bend the leads of the LED towards the pots.

Image Notes Image Notes


1. Feed a black wire through one of the holes in the middle. 1. Solder it to the left side to the pot.

Image Notes Image Notes


1. 20 AWG wire. I used needle-nose pliers to accomplish this. 1. Solder it to all the left sides of the pots.

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes Image Notes
1. Using some thing red wire, I connect these to all the right sides of the pots. 1. Here is the where the you solder a red wire to the right side of the pots.
2. Test. Hook up the red wire to 5v on Arduino and the black to GND. Connect
your multimeter to GND. Connect the red wire (of the multimeter) to the middle pin
of the pots. Turning the pot should give you a read of 0 volts through 5 volts.

Image Notes Image Notes


1. Solder the ground of the LEDs to GND. 1. Get these pots as level as possible!

Step 3: Ribbon Cable Dissection & Soldering


Ribbon cable! My good friend gave me this from I guess his old computer. Whatever the FD drive is! So, using razor blade, separate 8 wires from the rest. Then I used
some wire cutters to cut it. Strip the ends of the wires.

Soldering:

Working with ribbon cables can be tricky, but I found a way to master it. Draw a diagram! You can see in my diagram (the top) where everything should go. The bottom is
just everything reversed because when I was soldering I was soldering with it upside down.

Image Notes
1. What's an FD drive??
2. What's this all about?? Sloppy Dell manufacturers? :D

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes Image Notes
1. Using razor blade, separate 8 wires from the rest. 1. Clip the ends off.

Image Notes Image Notes


1. Using the razor blade again, separate all 8 individual strands. (if you noticed 1. Using the razor blade AGAIN, I stripped the ends.
there are 10 here, I mis-calculated how many I needed, don't ask)

Image Notes
1. Plans :D

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes
1. All the ribbon cable soldered. Notice the wire 1 is soldered to the middle pin of
the pot all the way to the right. Then LED are also connected.

Step 4: Arduino Backpack


This is what others call a "shield", but I like 'backpack'. Now what's the purpose of this? It's so that if you need to use your Arduino for something else, you can just pull it
off the top of the Arduino. If you want it back on, you can just push it right back onto Arduino!

1. Lay the perf board on top of the the Arduino. Then stick some pin headers through the perf and into the Arduino's output pins. This is to hold the perf board on the
Arduino. Using a sharpie, outline the Arduino on the perf.
2. Cut the perf
3. Mark a rectangle in the middle. Use a dremel to cut it out. I was able to cut it about halfway, then knock it out with a screwdriver.
4. Cut off the pin headers. (1, 2, 2, 4,)
5. Place all the pin headers into the Arduino pins. (the 4 goes into pins A0-A3, one of the 2 goes into 5v and GND, the other 2 connects to pins 12 and 13, and the 1
goes into pin 9.)(see pictures)
6. Put the piece of perf on top of the Arduino, letting the pins slip in the holes.
7. Put a drop of solder on top of the pins to hold them in.
8. Feed the ribbon cable though the rectangle.
9. Make all the solder connections. Be careful! Don't forget the resistors, pins 12 & 13!
10. Cut off the connector of the servo and strip the ends.
11. Attach the battery pack's positive and negative to the positive and negative of the servo. Solder these connections
12. Solder the GND of the battery and servo to GND on Arduino
13. Solder the control wire of the servo to pin 9.

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes
1. HEAVY DUTY!

Image Notes Image Notes


1. And here, too. . . 1. For the servo (pin 9)
2. The saw kinda slipped and finished the cut really fast. . . 2. For the pots (pins A0-A3)
3. For the LEDs (pins 12, 13)
4. For 5v and GND (pins 5v & GND)

Image Notes
1. Stick all the pins in the Arduino where they belong.
http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes Image Notes
1. Make a rectangle big enough for the ribbon cable to fit into. 1. Using my dremel I managed to get these cuts in. I was then able to knock it
out with a screwdriver.

Image Notes Image Notes


1. Begin to solder the ribbon cable to the corresponding pins. Don't forget to 1. Add a little glue for support.
look at your diagram!!

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes Image Notes
1. Solder two 200-400 ohm resistors on pins 12 and 13 1. Don't forget which wire is which!

Image Notes Image Notes


1. Add some glue under here as well for some support. 1. Yeah, almost done soldering!

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes
1. Solder the control wire to pin 9.

Image Notes Image Notes


1. Battery pack with stripped ends. 1. Solder positive from servo to the positive of the battery.

Image Notes Image Notes


1. Solder the negative of the servo and battery together. 1. Solder the GND of the servo and battery to the GND on Arduino.

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes Image Notes
1. Bend the positive wire over. 1. Slide on some heat shrink.

Image Notes
1. Servo
2. Battery for servo
3. Arduino with backpack!
4. I guess I haven't yet showed you how to make this :D. We'll get to that here
shortly.

Step 5: Making the Front Panel


So I just took a piece of basswood and marked off where all the potentiometers where. Then I took a ruler and drew the same marks in the middle. Using a 3/8 drill bit, I
cut drilled all the holes. MAKE SURE then pots fit in and are nice and level!

When you are putting on the ring terminals, MAKE SURE THAT THE POT IS TURNED ALL THE WAY TO THE LEFT FIRST!

Calibrating-
To do this you need to load the sketch (at the end) to your Arduino and open up serial monitor. Slowly turn the knob, in serial monitor when it says 1, make your first
mark. When it says two, make your second mark etc..
Making a frame-
Using some basswood sticks, I cut them to length and glued them on the edges. See photos.

I attached some double-sided tape to the battery holder, Arduino and the wooden frame.

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes
1. After sticking the pots in their holes, I was able to get these markings for the
LEDs.
Use a 1/4 drill bit.

Image Notes
1. 1/4 for LEDs

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes Image Notes
1. Optional, LED holders. 1. Everything fits, and I chopped of the edges.

Image Notes
1. After you turn the pot ALL THE WAY TO THE LEFT, dab some glue on top of
the knob, then press the the ring terminal on it. Then use your thumb to smash the
glue down that comes up through the ring.

Image Notes Image Notes


1. All glued on. 1. The markings, the first line is one, the second is two, etc.

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes
1. All the knobs marked.

Image Notes
1. Border all done!

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes
1. Double sided tape added to everything.

Step 6: Making the Servo Holder


So I'm sure you can use some type of aluminum sheet metal, some type of laser cut acrylic, or 3D printed holder, but I don't have any of those. So I used a metal lid to a
game. I was able to use my old pair of scissors to cut it up. BE CAREFUL, THE EDGES ARE SHARP! What I did is kinda hard to explain so just go through the photos
one by one.

Image Notes Image Notes


1. This is what we are trying to make. 1. $5

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes Image Notes
1. Stick a small screwdriver through here and give it a good pound. Make sure it 1. These two outer holes should be vertical, not crooked!
is not crooked like shown in the picture.

Image Notes Image Notes


1. I used a 1/4 to drill these holes out. 1. Stick your scissors in one of the holes and cut across to the other one. You
can now cut away until it looks like the next picture -->

Image Notes
1. Somehow with scissors I cut this rectangle out. It's for the middle piece to slid
through.

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes Image Notes
1. Yeah! 1. I wound up cutting off this top piece, I only need the bottom one.

Image Notes Image Notes


1. Forget this top one. 1. This is what we are trying to make.
2. Bend it at a 90Ëš angle.

Image Notes Image Notes


1. Using some hot glue I secured the servo arm to the lock. 1. You can see how I cut this piece and bent it.
2. I bent sheet metel up and glued it to the servo.

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes
1. I only got one small cut!

Step 7: Final Pictures

Image Notes
1. The inside of the door.

Image Notes
1. NOO! I forgot! :D
http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
Image Notes
1. Ahhh, better :D

Step 8: Breaking Down the Arduino Code


Now the whole point is to learn, right? So what were going to do is start with adding all of the pins.

#include<Servo.h>
int redLED = 12;
int greenLED = 13;
Servo myservo;

Explanation. #1 is line 1 in the sketch, #2 is line two in the sketch etc..

1. Including the servo library


2. Setting redLED to pin 12
3. Setting green LED to pin 13
4. Naming the our servo 'myservo'

Now lets take a look at our setup.

void setup()
{
Serial.begin(9600);
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
myservo.attach(9);
}

1. Serial.begin(9600) - begins serial communication at 9600 bits per second. This is typically referred to as the buad rate.
2. Setting redLED to output
3. Setting greenLED to ouput
4. Attaching the myservo to pin 9

void loop()
{
int analog1 = analogRead(A0);
int pot1 = analog1 * (10.0 / 1023.0);
int analog2 = analogRead(A1);
int pot2 = analog2 * (10.0 / 1023.0);
int analog3 = analogRead(A2);
int pot3 = analog3 * (10.0 / 1023.0);
int analog4 = analogRead(A3);
int pot4 = analog4 * (10.0 / 1023.0);

1. All this is for taking an analog reading at pins A0-A3. The analog reading is 0-1023. The line under it is converting it to 0-10. This is quite important, so don't get it
wrong!

if (pot1 == 4 && pot2 == 5 &&


pot3 == 6 && pot4 == 1)
{
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
myservo.write(90);
}

else
{
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
myservo.write(170);
}

1. This is saying, "If pot1 is equal to the value 4, pot2 equal to 5, pot3 equal to 6, and pot4 equal to 1, then do the functions in the block right under it.
2. Turn green LED on, turn red LED off, and turn the servo to 170Ëš. (note: you will have to play with the servo to get it to turn correctly. Start off with 90Ëš and work
your way up and down.)
3. If all of those statements aren't true, then run the else block.
Turn the green LED off
Turn the red LED on
Move the servo back to 90Ëš

Step 9: Final Arduino Sketch


If you can tell the code is 4561. Note: You will most likely have to change the servo values. Start off with 90Ëš and slowly work your way up and down. You don't want to
break your servo! For powering your servo I used the USB cable and a USB cell phone charger.
Oh, and also, the Serial.print(pot1,2,3&4) is for adjustments.

#include<Servo.h>
int redLED = 12;
int greenLED = 13;

Servo myservo;

void setup()
{
Serial.begin(9600);
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
myservo.attach(9);
}

void loop()
{
int analog1 = analogRead(A0);
int pot1 = analog1 * (10.0 / 1023.0);
int analog2 = analogRead(A1);
int pot2 = analog2 * (10.0 / 1023.0);
int analog3 = analogRead(A2);
int pot3 = analog3 * (10.0 / 1023.0);
int analog4 = analogRead(A3);
int pot4 = analog4 * (10.0 / 1023.0);

if (pot1 == 4 && pot2 == 5 &&


pot3 == 6 && pot4 == 1)
{
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
myservo.write(90);
}

else
{
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
myservo.write(170);
}

Serial.print(pot1);
Serial.print(pot2);
Serial.print(pot3);
Serial.print(pot4);
Serial.println();

Step 10: Conclusion:


I hope you guys enjoyed this i'ble! If you like it, vote it as a winner for the UP contest and the Make-to-learn Contest!
Please post your pictures of yours and if you have any question leave them in the comment box below or PM me.

Bonus!

If you post a picture of your own lockduino, I'll give you a 3 month pro membership! Only for the first two posters without pro memberships!

Cheers!

Related Instructables

Arduino Interface Python


Sci-fi B-movie Arduino XMAS standalone web and Arduino Arduino + 2
goggles by cypy hitcounter by enabled bell with pySerial by Servos +
Arduino alex_weber (Photos) by Thumbstick
animatronics- Hammock Boy
SimonUK (joystick) by
make your biomech75
awesome
costumes more

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/
awesome! by
Honus

Advertisements

http://www.instructables.com/id/Arduino-Combination-Lock-Lockduino/

You might also like