Introduction: Arduino Combi-button Lock W/ Optional IOS/Android Support

Picture of Arduino Combi-button Lock W/ Optional IOS/Android Support

Recently, I decided I would like to attempt to make a passcode lock with my newly acquired Arduino Uno, but all the tutorials I could find made use of a modified keypad, something that not every Tom, Dick and Harry has lying about. I therefore decided to set out and make a version using only things every Arduino user should have in their component box - buttons.

Ladies and Gentlemen, I bring to you - the Arduino Combi-button Lock!!

This example will cause only an LED to come on when the passcode is entered, but other features can easily be added, such as a servo, motor etc.

If you do not wish to use buttons, there is an alternative TouchOSC version for Android or iPad/iPhone/iPod touch. Just skip step 4.

This is an entry for the Microcontroller contest. If you think it's awesome, be sure to vote!

So let's get started!

Step 1: Components - What You Will Need

Picture of Components - What You Will Need

To make this lock, you will need:


Essentials

-> An Arduino board - in my case an Arduino UNO I purchased from oomlout.co.uk. I bought the starter kit, and I would highly recommend it - go check them out!
-> A USB type-A to USB type-B cable
-> The Arduino IDE - download from arduino.cc
-> A breadboard

Hardware version:
-> 4 x push buttons/switches
-> 4 x 10k ohm resistors

iPhone/iPod Touch OSC Controlled version:

-> TouchOSC app ($4.99 on AppStore, and I believe it is free on Android)
-> TouchOSC layout editor
-> The Processing IDE - download from processing.org

Step 2: Preparation - Setting Up the Breadboard

Picture of Preparation - Setting Up the Breadboard

Plug one of the bus rails along the side into the 5v pin on the Arduino

Plug another bus rail into a ground (GND) pin on the Arduino

Step 3: Let There Be Light! - Setting Up the LEDs

Picture of Let There Be Light! - Setting Up the LEDs

Plug both the LEDs into the breadboard, longer leg on the left ( to make following this tutorial easier).

Next, plug a 560ohm resistor into the rail connected to the longer leg (+ve) of each LED, and take the red LED's resistor to Arduino digital pin 4. Then take the other end of the green LED's resistor to pin 12 on the Arduino.

Finally, take a jumper wire, and join the other leg of the red LED to the GND bus rail, and do the same for the green LED.

Step 4: Physical Version - Buttons

Picture of Physical Version - Buttons

OK, I will walk you through one button, and the same process must be repeated for the other three.

Please Note: It is important that none the buttons are connected to the same rows occupied by the LEDs (two for each or three for each, depending on which setup you chose in the previous step).

Plug a button over the gap in the middle of the breadboard - make sure this goes the right way round. You might have to bend pins.

Next, plug a 10k ohm resistor from one leg of the button to the GND bus rail, and use a jumper wire to connect the other leg on the same side of the gap to the 5V rail.

The next step is a little harder to explain - connect digital pin 8 on the Arduino to the rail which contains a leg of a 10K ohm resistor and a leg of a button. Look on ladyada's website for a more detailed explanation.

Set up the other buttons the same, with the second going to pin 9, the third going to pin 10, and the fourth going to pin 11.

You can now skip to the code section.

Step 5: CAN Touch This - TouchOSC Version - Creating the Layout

Picture of CAN Touch This - TouchOSC Version - Creating the Layout

First, we must create the layout for TouchOSC. Open up the editor that you should have downloaded in step 1.

Next, create 5 toggle buttons by right-clicking. 4 will be the buttons to enter the code, and one will be the set/reset button. You can position these as you like, just be sure they are named as follows (from left to right):

-> The first is named toggle1
-> The second is called toggle2
-> The third is toggle3
-> The fourth is toggle4
-> And the reset button is called toggleReset.

See a screenshot of my layout above. I also added a label saying RESET, but this is optional. Labels numbering the buttons could also be added.

Save this layout as Passcode Buttons, or anything really, so long as it describes what the layout is.

Step 6: TouchOSC Version - Syncing the Layout

Picture of TouchOSC Version - Syncing the Layout

Open the TouchOSC app on your Android/iDevice, and make sure your PC and your device are on the same WiFi network.

On the TouchOSC editor, hit "Sync".

Back on the app, tap "Layout", then add, and select your PC from the list.

Your new layout will now be added onto the list.

Step 7: TouchOSC Setup

Picture of TouchOSC Setup

On the main menu of the app, tap the OSC entry under the "Connections" heading.

Make sure the options are as follows:

-> Enabled - On
-> Host - enter your computers local IP address here. You can find this by going to your PC and opening a command line
              
             - If you are on Windows, type "ipconfig". I don't use Windows, so I can't tell you exactly what to look for. A quick Google search will  provide more info
             - For Mac or Linux, use this command: ifconfig | grep "inet " | grep -v 127.0.0.1, and take the first entry (four numbers separated by periods)

-> Port (outgoing) - 8000
-> Port (incoming) - 9000


Step 8: The Code

For the physical version:

Open the Arduino IDE and upload the Passcode.pde file to your board. By default, the passcode is 1,2,3,4. You can change this by modifying the numbers in the code[] array at the top of the code.

Once the password has been correctly entered, the reset button on the arduino must be pressed to reset the lock. This is intentional.

For the TouchOSC version:

Before you can upload this code, you must download the Arduino library for Processing (the version for the Arduino Mega can be found here ), and also the OscP5 Library . Install these by extracting them, and dropping the folders created into the "libraries" folder in your processing sketchbook (if it is not there, create it).

Next, upload the "Standard Firmata" sketch, found in Examples>Firmata, to your Arduino board.

Finally, run the PasscodeOSC.pde processing sketch.

Now, when using the TouchOSC app and the layout we created, you should be able to type your passcode. Bear in mind that the processing sketch MUST be running on your PC in order to function.

Again, the passcode can be change in the code[] array at the top of the Processing sketch.

If there are any questions, let me know in the comments.

Remember to vote if you like this Instructable!!

Thankyou and goodnight!!

Comments

DeguiK (author)2015-07-28

It seems you have to change:

Serial.print(Serial.read(),BYTE); line to Serial.write(Serial.read());

This is:

Serial.write(entered[i]);

punrau (author)DeguiK2017-02-15

I am also getting a lot of the "checkEntered1" errors. Is this the salutation? Bc there is no line "Serial.print(Serial.read)(),BYTE); in the code at all, there is only
Serial.println(entered[i], BYTE); which is the closest but i replaced it and it still didn't change.

Gaige Kerns (author)2015-02-12

Your Code Needs to be modified because the arduino platform doesn't like your use of "BTYE" parameter if anyone wants to see the updated code msg me.

MarenK2 (author)Gaige Kerns2016-11-18

Hi! Could you send me the updated "Arduino Combi-button Lock w/ optional iOS/Android support" code? :)

e-mail: marenknudsen@hotmail.com

Thanks,

Maren

Hi,could you please send me the code too?

Sorry, I don have it anymore.

MartijnS1 (author)Gaige Kerns2015-12-16

Hi! Could you please send me the modified code as well?

jstein54 (author)Gaige Kerns2015-05-01

Could you please send me the modified code?

kaydenr (author)Gaige Kerns2015-04-17

I would like to see it.

RussC1 (author)Gaige Kerns2015-04-14

Hi, could I see the updated code?

KuriGohanandKamekameha (author)2016-01-15

How do you declare the checkEntered1?

KuriGohanandKamekameha (author)2016-01-15

How do you declare the checkEntered1?

chrisidh07 (author)2015-12-19

I get an error from the passcode.pde that "'checkentered1' was not declared in this scope". Please help?

Emiliano Valencia (author)2011-07-20

where did you make those schematics? (the ones with the Arduino and Breadboard drawings)
thaks!

Or you could go to 123d.circuits.io and its free and its online.

download the free program 'fritzing', it allows you to make these diagrams along with real schematics as well as PCB layouts!

Thanks! I've seen this all over the internet and never found how to make them

Not a problem buddy, make sure you share this ible with your friends :)

KGuy (author)2012-11-25

Hi! Good job on the instructable! I've been screening the site everywhere, trying different arduino projects. When I came here, I built the circuit with no problem (not the OSC version), but when it came to the code, nothing worked. Might have been the layout, but I'm not sure. Any suggestions?

blubberdubber (author)2012-04-06

Hi, thanks for the great instructable! I'm new to arduino and this is set to be my first project on the arduino board. I was planning to use the TouchOSC version of your project but I am not sure how to actually make this work as a lock. Please can you advise me on how to install this on a door and actually make a lock.

Also, being new to arduino I can't visualise your project. I am curious how (for the TouchOSC version) it would work. Do you type in the password on your phone and then the door opens?

Many Thanks.

About This Instructable

28,197views

53favorites

License:

More by samwhiteUK:Arduino Combi-button Lock w/ optional iOS/Android supportHow to install Windows Vista (sort of) on a PSP.
Add instructable to: