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
- Arduino Uno (or any other arduino)
- 1 x ATtiny84 + Socket for it
- 1 x Keypad
- 1 x Servo
- 1 x Green led
- 1 x RGB led (I am using common anode RGB led)
- 1 x Switch
- Power supply (I used an old mobile charger, with 5.3V output and 500mA)
- 10uF capacitor
- Libraries required for the code, which is attached at step .
- 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.
- Download the Keypad library attached in this step.
- Import it into arduino by clicking Sketch>Import Library>Add Library and selecting the Keypad.zip
- Upload the HelloKeypad example to your arduino (change the code if you have 4x4 keypad)
- Connect the keypad to arduino.
- If you are getting correct key in the Serial monitor, you have connected it correctly. Note down the rows and columns pins.
- If not, reverse the connection and try again.
Step 3: Circuit Diagram
Step 4: Making the Circuit
- Attach switch, green led and RGB led to the lid of your box.
- Cut out a small piece from your board( 12 holes x 12 holes will be enough)
- Place the DIP socket in the middle of board.
- 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.
- 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.
- 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.
- 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.
- 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.
- Connect the wire coming from switch to the diode/VCC of the attiny84, along with positive wire from servo.
- Connect negative wire from battery, negative wire from servo and wire from cathode of green led to GND of attiny84.
- Lastly, connect the pulse pin of servo to pin 7 of attiny84.
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.
Participated in the
Home Technology Contest