Introduction: Keypad Lock With Servo Using ATtiny84

In this instructable, we will be making a combination lock to your door, with a keypad and servo, using ATtiny84.

But we can't use the Servo library included in the Arduino IDE, as ATtiny84 just has 2 8-bit timers and no 16-bit timer, but the Servo-library relies on having a 16-bit timer available. So, we have to use another library, SoftwareServo.

We will be making the lock with two passwords, one for unlocking and other for locking. '*' key is used to enter the password while '#' clears the password. Blue color blinks whenever a key is pressed, green for correct password and red for wrong.

Step 1: Items Required

  1. Arduino Uno (or any other arduino)
  2. 1 x ATtiny84 + Socket for it
  3. 1 x Keypad
  4. 1 x Servo
  5. 1 x Green led
  6. 1 x RGB led (I am using common anode RGB led)
  7. 1 x Switch
  8. Power supply (I used an old mobile charger, with 5.3V output and 500mA)
  9. 10uF capacitor
  10. Libraries required for the code, which is attached at step .
  11. An enclosure box

Step 2: Identifying Pins of the Keypad

If your keypad doesn't indicate the rows and columns pins, follow the instructions to identify it.

  1. Download the Keypad library attached in this step.
  2. Import it into arduino by clicking Sketch>Import Library>Add Library and selecting the
  3. Upload the HelloKeypad example to your arduino (change the code if you have 4x4 keypad)
  4. Connect the keypad to arduino.
  5. If you are getting correct key in the Serial monitor, you have connected it correctly. Note down the rows and columns pins.
  6. If not, reverse the connection and try again.

Step 3: Circuit Diagram

Step 4: Making the Circuit

  1. Attach switch, green led and RGB led to the lid of your box.
  2. Cut out a small piece from your board( 12 holes x 12 holes will be enough)
  3. Place the DIP socket in the middle of board.
  4. Solder 7 breakout pins as shown in the figure. The yellow wire is used to connect the last column to pin 6 of attiny on the other side.
  5. I am using a 5.3V adapter for powering the circuit. But maximum input voltage of ATTiny84 in 5V. So, I used a diode(In4001) do drop the voltage by 0.7V.
  6. Solder one 1KΩ, one 470Ω resistor and a wire to one pole of the switch. To the other pole, solder wire coming from the positive terminal of the battery.
  7. Solder the 1KΩ resistor to anode of green led, 470Ω resistor to anode of RGB led. Also solder one wire to cathode of green led.
  8. Connect red pin of RGB led to pin 8, blue to pin 9, and green to pin 10 of attiny84. Please note that there is a reset pin between pin 8 & 9.
  9. Connect the wire coming from switch to the diode/VCC of the attiny84, along with positive wire from servo.
  10. Connect negative wire from battery, negative wire from servo and wire from cathode of green led to GND of attiny84.
  11. Lastly, connect the pulse pin of servo to pin 7 of attiny84.

Step 5:

Download the arduino sketch and the libraries needed attached in this step.

NOTE: If you are using the SoftwareServo library downloaded from the Arduino website, replace #include<WProgram.h> with #include "Arduino.h" in the SoftwareServo.h file.

Step 6: Uploading Code to ATtiny84

Follow this instructable for uploading code to ATiny84.

Step 7: Done!

After uploading the code to ATtiny84, put it into the socket of your circuit.

That's it! Now you have a keypad controlled door lock, powered by ATtiny.

You can use the servo to operate different kinds of locking mechanisms. Choose the one which suits you. Alot of it can be found here on this site itself.

Home Technology Contest

Participated in the
Home Technology Contest