GARAGE ACCESS GOES
BY JAY CARTER, MD
An electric garage door opener is one of
the greatest convenience devices ever
created! Rain or snow, the weather
doesn't matter. You hit a button from
inside your car and the door instantly
performs as commanded. By adding a
digitally controlled keypad, one can
make keyless entry easy for children, too.
This project uses a single chip — an ATMEL AVR
ATtiny2313 microcontroller — to read a keypad and
trigger activation of up to two garage doors. The four digit
access code can be programmed using the keypad itself,
allowing one to easily change the code as desired. A
built-in safety feature will stop the door with the single
press of any key following door activation. Using only
a handful of components, this becomes a truly useful
weekend project. Photo 1 shows the project assembled
and ready for installation.
Garage Door Interfacing
Most garage doors can be activated via two methods:
a doorbell type pushbutton switch or wirelessly. This
project mimics the doorbell switch, so it keeps costs
down and eliminates the need to know your garage door's
wireless frequency and encoding. On the back of most
garage door units are two terminals which are wired to the
pushbutton switch. The microcontroller activates a small
relay when the correct access code is entered. The relay
contacts are tied to the same terminals as the pushbutton
switch. Enter the code and the microcontroller effectively
pushes the button for you.
Reading a Matrix Keypad
The circuit for this project (shown in Figure 1) is
centered around the microcontroller. The selected
keypad has 16 keys, connected in a 4 x 4 matrix
arrangement. Four wires connect to the four rows of keys,
while four more wires connect to the four columns of
keys. Pressing a key shorts the associated row and column
wires together. For example, pressing the " 6" key ties the
■ PHOTO 1. The garage access keypad project shown
completed and ready for installation.
One chip — the ATtiny2313 — runs the show.
It scans the keypad, validates an access code,
and drives two relays, activating the garage doors.
The weatherproof enclosure includes a rubber gasket.
row 2 and column 3 wires together.
The microcontroller can scan the keyboard and tell
if any key has been pressed. To do this, the four column
lines are pulled high to + 5 volts by resistors R4-R7. The
microcontroller outputs a 1, or +5V on each of the
four row lines. Then, one row at a time, the
microcontroller outputs a 0 on the row line, pulling it low.
The microcontroller then reads in the state of each of
the four column lines. If one of the keys in that row is
pushed, its column will be low. If there are no keys in
that row pushed, all four column inputs will read high,
being pulled high by the pull-up resistors. As an
example, if the " 9" keypad is pressed, the row 3 and
column 4 lines are tied together. When the
microcontroller pulls row 3 low, columns 1, 2, and 3
will read high, while column 4 is now connected to the
low level and is read as low.
The microcontroller stores the sequentially pressed
keys in a first-in, first-out (FIFO) buffer. The access code
is four digits long, followed by the "Enter" key. If more
that four keys are pressed, the oldest key press is
overwritten, with the program always having the last four
keys in the buffer. When "Enter" is pressed, the program
checks the last four key presses against the access
code. If a valid code was entered, the microcontroller
activates a relay and closes its contacts, mimicking a
doorbell pushbutton switch being pressed.
Holding the relay closed for about 3/4 of a second
works well on my door openers, but the value can be