Portcullis

Created by [Jayden Leung (Hack Club Slack: loliipoppi)] • Started on July 01, 2025

Automatic remote locking and unlocking system for home security door reinforcement locks moving along two conflicting axes.

Time Spent

  • Total hours excluding prior work: 92h
  • Total days excluding prior work: 16 days
  • Total days in prior work: ~3 days
  • Time spent on CAD: 17h
  • Time spent on PCB design: 4h
  • Time spent on coding: 4h
  • Time spent on physical assembly: 62h
  • Time spent on sourcing parts, writing journal and readme, etc.: 5h

Prior Work

Originally, this project was called the Keypad Autolock when I worked on it before Highway. However, I didn't have much of the project complete before Highway, so I decided that this could likely count for a project submission after consulting with others in the Slack. Specifically, I had the case for the keypad, a model of the lock, a housing for the servo, and ideas for a linear actuator, among others, in place before Highway. When I began this project for Highway, I still spent time doing research to figure out the most effective ways to navigate this mechanical engineering problem. I have still spent a significant amount of time in CAD, and I haven't done any prior PCB design work or firmware coding on this prior to Highway.

The Keypad Autolock, now Portcullis (meaning the waffle-like iron gates that historically guarded castle doors following the drawbridge), is designed to open home security door reinforcement locks (HSDRLs) remotely using a keypad on the other side of the door. Alternatively (maybe in the future), I'm hoping that I can integrate remote connectivity to unlock and lock it from my phone.

Total time spent (prior to Highway): 7h

July 1: Research

Prior to starting the project, I made sure to do my research. An HSDRL is a two-stage lock; it must first be pulled outwards and, after, rotated to be unlocked. However, the reason they were so secure - and difficult to unlock/lock with a mechanical design - is that these two axes were not the same. Consider an XYZ space with the Z axis pointing up/down and the XY plane lying flat. The HSDRL must first be pulled linearly along either the X/Y axis (a 'flat' axis) and then be rotated about the Z axis. This makes designing a remote locker/unlocker difficult as there needs to be two parts to the design. This also makes this project highly mechanical.

67695ae9-2831-491d-8d26-9c6d92e1358c __CR0,0,970,600_PT0_SX970_V1___

From my prior work, I already had an idea of how it might work, but I wanted to see if there were more effective ways to go about it. I finally settled on the method that made the most sense to me. This was to incorporate a linear actuator to push the lock outwards and then rotating the lock with a servo. Below is the finished CAD design (the research was done beforehand, the diagram is just there to visualize the system better), which illustrates the above explanation. I also realized halfway through designing it that I overcomplicated the design and that the entire linear actuator part could be simplified by having the screw go through the U-shaped part and locking the U-shaped part's ability to rotate. However, I didn't want my work to go to waste, so I decided to continue, which also benefitted me in allowing me to learn more about springs and linear guide rails.

Screenshot 2025-07-07 at 4 30 50 PM

Total time spent: 1h

July 1-7: CAD

Then came the bulk of the project - CAD. Since this was a mechanically heavy project, I spent a good amount of time - about a week - on this part. Below is an in-depth explanation:

Keypad frame and housing: - Housing box for the keypad, LCD, and PCB on the other side of the door - Includes mounting holes on the housing and a hole for wires to exit the housing and travel under the door and to the Arduino microcontroller

Screenshot 2025-07-07 at 4 32 23 PM

Linear actuator: - Uses a continuous micro servo attached to a screw - The housing for the servo allows it to slide linearly and includes a nut - When the screw turns, it interacts with the nut and pulls itself and the servo forward - The screw also touches (but is not connected to) the U-Pusher, a U-shaped part which pushes the lock linearly when the servo extends - this is the first step to unlocking the lock - The U-Pusher and the servo housing are independent of each other and are not connected - The U-Pusher and the servo housing are connected to a linear guide rail which allows the U-Pusher to slide closer and farther from the servo housing as the screw pulls forward/backward - Springs are mounted to the U-Pusher and servo housing to keep the screw and U-Pusher together but not physically connected (implemented for when the screw retracts)

Screenshot 2025-07-07 at 4 33 00 PM

Rotational device: - A cap is mounted onto the lock with two prongs extending upwards - Another cap with one prong extending downward is mounted onto a positional servo and sits just to the side of the cap on the lock - When the linear actuator pushes the lock, the prongs on both caps slide into place, next to each other - The positional servo then turns the lock ~100° to fully unlock it - (The linear actuator then retracts the screw to fix the lock into the unlocked position)

Screenshot 2025-07-07 at 4 36 20 PM

Total time spent: 12h

July 7: PCB and Wiring

After I finished CADing, I moved onto PCB design. Now, after I finished designing my entire two-part PCB, I realized that it was much too impractical to even install one; in other words, I'd just wasted hours of my time. However, I wouldn't say it was entirely wasted, since I learned some valuable lessons:

One, think before you do! I tried this out when I was in the middle of designing the PCB late at night and realized what I was doing would overcomplicate the design and that there was a much simpler, faster, and more effective way to design my PCB. Two, I gained more experience and practice in PCB design, drawing footprints, etc. I found KiCAD's array feature which helped me to add multiple of the same type of through hole at once, saving me a lot of time and effort. Three, I needed a schematic anyway, and it helped me with my wiring diagram that I ended up making instead.

The PCB was not needed since different parts were on different sides of the door, and besides, even the servos that were on the same side were physically separated. It didn't make sense to have a PCB since I could not effectively mount all the parts. Instead, I would pass the wires under the door and plug them into the Arduino microcontroller, making sure to solder the 5V wires together and to secure the pins so that they wouldn't move.

Here's the schematic that I made: Screenshot 2025-07-10 165348

Here's the PCB that I made (I saved it anyway): Screenshot 2025-07-08 at 2 15 36 PM

Here's the wiring diagram that I'll be using: unnamed

Total time spent: 4h

July 8: Additional CAD

Usually, this would be the step where I would make changes to my CAD design to incorporate the PCB I just created. However, since a PCB wasn't needed for this project, I instead took this time to create a housing for my microcontroller, which also included a button I forgot to account for earlier. This button would also lock and unlock the door without needing a password (since it would be behind the door).

Screenshot 2025-07-10 182612 Screenshot 2025-07-10 182758 Screenshot 2025-07-10 182809

As you can see, I got a bit carried away in designing the case. I found a text FeatureScript in Onshape (a program that allowed me to add text into my CAD model), which would have been really helpful for my other hackpad project (I spent about an hour writing the text by hand using lines and curves). After that, I decided to make the case look like a real, medival portcullis, and I also wanted to include the button in the middle. It was nice to learn how to incorporate aesthetics in my CAD designs, though!

Additionally, I fixed up a few minor details with the servo housing and its cover. I also moved the hole in the keypad housing for the wires to pass out of to the bottom so I could attach my wire cover directly to the case.

Total time spent: 5h

July 9-10: Firmware Coding

For the final piece of designing this project, I coded the firmware. It consisted of a few different parts: controlling the servos and the locking mechanism, the keypad logic to decide when to unlock or lock it, and updating the UI on the LCD. Coding the mechanical control of the servos wasn't too difficult except that I needed to get the angular speed of my continuous servo empirically, and I did not have the tools to do that at the moment. Instead, I went with 130 RPM, which is what the internet said was its max speed.

After that, I coded the keypad logic, which surprisingly was not as difficult as I imagined. Many conditionals, yes, but nothing too complicated. '*' meant clear the PIN, '#' meant enter, and everything else - including letters A-D and numbers 0-9 - was fair game for the PIN. However, the code began to get messy after I added in LCD text and LED light logic on top of that. But a few void-type functions for organization easily cleaned it up.

I thought I was finished, but it turned out that I had forgotten to include code for the LED light-up button on the inside of the door that allowed me to unlock and lock it without a passcode. It took me a few tries and some help from ChatGPT before I could get edge detection down, but I finally finished the program in 189 lines.

Screenshot 2025-07-10 173544

Total time spent: 4h

July 27-August 1 - Putting It All Together, Mechanically

A huge package of all my materials came today (July 27), and since I previously had used my 3D printer to print all of the parts, I began putting it together. Here are some issues I encountered:

  • The nut and screw I 3D printed didn't mate well, so I had to use a similar nut that I prototyped with before (that did work). I hot glued it onto the linear (continuous) servo housing. I also had to modify the housing a bit to fit the servo better.
  • The hooks I made for the springs were way too thin, so I reprinted the housing with thicker hooks. This allowed me to put 4 springs on each of the two hooks, which provided excellent tension as the linear guide rails were a little rough.
  • The linear guide rails were really greasy when they arrived, probably really coated in WD40 or another lubricant. I wiped them down with a tissue.
  • The screws fit well with the 3D printed parts, BUT HERE'S A BIG LESSON I LEARNED: 3D printed hole sizes can be smaller than it is in CAD! Especially since I didn't have a really high quality Bambu or similar. I ended up having to scrape out some of the plastic in the hole to make it bigger and use a smaller screw.

Mechanically, the linear actuator worked well (except that the nut was falling off at the end), but the rotational actuator was a bit more of a pain. I reprinted it to be bigger, which helped to solve the problem.

IMG_4029

IMG_4031

July 27-August 1 - Putting It All Together, Electrically

Ok, this was a HUGE pain. I literally spent two to three hours trying to figure out why my LCD module wasn't working, only to realize that the two LED jumper pins weren't connected. The biggest lesson I learned from this was probably about part sourcing and electronics in general.

1. Never buy from Aliexpress, but always buy from Aliexpress.

Wait, what? What I really mean is that the quality in Aliexpress is a lot lower than in Amazon or in-store, but they can have much cheaper prices. The best combination is to buy from an Aliexpress vendor that doesn't look sketchy (not the Shop12312093712 vendor I purchased from), has at least 100-500+ of that item sold, has really good reviews, and has been operating for a 3-5 years minimum.

Better to have a slightly higher price than to have to buy a whole new one to replace it. Low prices can be enticing - I can say that firsthandedly - but know they come at a cost. For example, I bought my keypad from a random seller on Amazon, and I didn't take the time to background-check their reputation before ordering it. I easily blew a trace on that keypad while soldering, rendering the entire thing useless.

2. Expect to spend a lot of time on each electronic component. As a general rule of thumb, think of a reasonable time it would take and triple it. That's the time you need

I spent a lot of time debugging, sometimes for the littlest things. Don't overlook the smallest things! Double check your wiring! Commonly used parts such as servos and buttons usually work, but remember to buy from a reputable seller. Sometimes the module is just broken or doesn't use the chip it says it uses to reduce manufacturing costs. It took me a long time to finally realize that I blew my keypad, and I couldn't use it (I couldn't get a replacement since I was leaving the next day, but I still mounted the broken keypad for the looks).

After that, I said I'd never become an electrical engineer (but computer engineer!). But now, I see that it might be kind of fun.

IMG_4025 | | V IMG_4026 | | V IMG_4027 | | V IMG_4034 | | V IMG_4048

July 27-August 1 - Putting It All Together, In The Code

I didn't initially use the code that I had previously designed since it was too fleshed out. Instead, I tested each part individually using example code. Surprisingly, at the end, my full code worked perfectly. It was kind of funny that the electrical part was the toughest, but the software somehow worked fine. Likely because I was using pretty simple and common parts for my build (servos, LCD modules, etc.).

July 27-August 1 - Putting It All Together, Finally

After many, many tries, I finally finished it before I had to go off on a trip (where I couldn't access it) by pulling an epic all-nighter. Recording the setup, I turned on my power bank, waited for the setup to activate... the linear actuator pulled the servo forward, pushing the the boltlock... the tab on the servo slid into place with the boltlock... the rotational servo turned, and... it unlocked!!! I was so happy after spending basically the past 21 hours on it (which was just that day). For something that was supposed to be so simple, it took a long time. But I learned many lessons along the way, and that's what counts. Enjoy the video of it below!

IMG_4044

Full Demo: https://youtu.be/WndzgAl9owI

P.S. It was meant to keep others out of my room, but the fragile setup seems to keep me more out of my room instead... maybe I'll improve it later!

Total time spent (for the entire physical assembly): 62h

Note: This took a long time, but the time to build electronics projects should decrease as I gain more experience. This was my first ever fully built-and-finished project!