{"id":52,"date":"2025-10-07T10:06:15","date_gmt":"2025-10-07T09:06:15","guid":{"rendered":"https:\/\/blinkbonnie.xyz\/?p=52"},"modified":"2025-11-13T03:29:53","modified_gmt":"2025-11-13T03:29:53","slug":"keypad-redux","status":"publish","type":"post","link":"https:\/\/blinkbonnie.xyz\/?p=52","title":{"rendered":"Keypad Redux"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"766\" src=\"https:\/\/blinkbonnie.xyz\/wp-content\/uploads\/2025\/10\/keypad.jpg\" alt=\"The picture shows a keypad made from the navigation keys and numpad of an old computer keyboard. The case is black and the keys are white with no labels. The status LEDs are missing but there is a new power LED in the top right corner of the case.\" class=\"wp-image-53\" srcset=\"https:\/\/blinkbonnie.xyz\/wp-content\/uploads\/2025\/10\/keypad.jpg 800w, https:\/\/blinkbonnie.xyz\/wp-content\/uploads\/2025\/10\/keypad-300x287.jpg 300w, https:\/\/blinkbonnie.xyz\/wp-content\/uploads\/2025\/10\/keypad-768x735.jpg 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>I was rooting around in my box of goodies the other day when I came across this old keypad and thought why not get it working?<\/p>\n\n\n\n<p>It\u2019s made from the numpad section of an old keyboard that I got when I cleared away all the old computers from a local High School. I had so many old AT keyboards that I ended up harvesting them for switches and cables.<\/p>\n\n\n\n<p>But anyway, this was one of at least two that I made into mini keypads using the original cases cut and glued.<\/p>\n\n\n\n<p>The keypad was fitted with a PIC based driver circuit but the PCB for the actual keys was separate and I figured it would be easy enough to fit a Raspberry Pi Pico inside and turn it into a working USB keyboard.<\/p>\n\n\n\n<p><strong>Mechanics<\/strong><\/p>\n\n\n\n<p>As it was, the two halves of the case were held in place with the original case screws on one side and taped with electrical tape on the side I had chopped. I wanted to dispense with the tape, so I needed to find a way to add screws. I ended up managing to epoxy a couple of threaded hex PCB standoffs inside the case and drilled through the bottom of the case to allow screws. It works fine but isn\u2019t perfect because I can\u2019t screw the rear edge tightly \u2013 the hex space doesn\u2019t span the internal space between the top and bottom halves of the case.<\/p>\n\n\n\n<p>I also needed to figure out how to fit the Pico. It\u2019s so small that mounting it is a challenge. I settled on using tiny screws to fit it to a piece of timber that I hot glued inside the case.<\/p>\n\n\n\n<p>I used a craft knife and a file to create an opening to allow the USB cable to plug in. That worked out fine.<\/p>\n\n\n\n<p>The case was originally beige, but I\u2019d spray painted it white long ago. It was looking a bit tired so I sanded it back a bit and gave it a coat of black paint. Looks fine.<\/p>\n\n\n\n<p><strong>Wiring<\/strong><\/p>\n\n\n\n<p>I unsoldered the existing PIC board and soldered header pin plugs to the cables. There wasn\u2019t space enough to use vertical header pins so I used 90\u00b0 pins.<\/p>\n\n\n\n<p>While I was inside the case I noticed that the original design included space for a speaker. I decided to take advantage of that and installed a small speaker, although I haven\u2019t yet figured out how to make the Pico make noise.<\/p>\n\n\n\n<p>The case had holes for LEDs (Caps lock, num lock etc) so I enlarged them enough to accept a 5mm LED bezel. I have a PCB designed that I will try to fit, but I\u2019m not sure there\u2019s enough room for it, so the LEDs may or may not be something that happens. I did add a power LED and that should work, even if it\u2019s the only one.<\/p>\n\n\n\n<p><strong>Programming<\/strong><\/p>\n\n\n\n<p>Well I thought MicroPython would have the libraries I needed to implement a HID keyboard and the documentation said it did but I couldn\u2019t figure out how to install it, so I flipped over to CircuitPython. I loaded the test program and got the Pico operating as a keyboard pretty easily.<\/p>\n\n\n\n<p>The thing is, I wasn\u2019t using discrete switches. My PCB uses an 8 x 4 array so I needed to implement an array scanning algorithm. That was achieved with a couple of FOR loops. The current limiting resistors for the columns were already incorporated into the keypad PCB and the pullup resistors for the rows were replaced by internal pullups in the Pico.<\/p>\n\n\n\n<p>After tracking down a couple of bugs I had a running program that scanned all 30 keys and sent key presses back to the PC. Then came half an hour of tracking down the actual key codes I needed to send so the keypad was actually usable.<\/p>\n\n\n\n<p>I\u2019m not sure about the numlock functionality. I might need to program that separately. Also I suspect that the keypad won\u2019t respond to numlock changes using the main keyboard. Still, I think I can get num locking working okay with a bit more code.<\/p>\n\n\n\n<p><strong>To Do<\/strong><\/p>\n\n\n\n<p>I don\u2019t need the keypad to spawn a window every time it is plugged in, so I\u2019ll have to investigate how to suppress that behaviour of CircuitPython.<\/p>\n\n\n\n<p>The LEDs are not wired in yet, so once I make the circuit board I\u2019ll have a go at that.<\/p>\n\n\n\n<p>The keys are blank. That\u2019s a little awkward. Maybe I can use the Dymo and make some labels or print some on a clear label. The Dymo works pretty well but we will see.<\/p>\n\n\n\n<p>I\u2019d like to try some different key mapping options. Not sure what, but I could use it for\u2026dunno. Something really useful. Than again my main keyboard already has macro keys that I\u2019ve never used.<\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>I think the project came out pretty well. The existing PCB is in excellent condition, for being possibly 20 years old. I\u2019d like to know where my other big keypad got to. I know it existed because I have pictures of it. Maybe there\u2019s another box of goodies. Yeah, nah. I know <strong>exactly<\/strong> what happened to it. <\/p>\n\n\n\n<p><strong>Addendum<\/strong><\/p>\n\n\n\n<p>So, it\u2019s after tea now and I\u2019ve spent an hour or so messing with the speaker. Getting the sound to play was as simple as creating a PWM output and getting it to play for a split second whenever the key status is changed, i.e. when the key is pressed.<\/p>\n\n\n\n<p>I took the opportunity to add some silliness. The program checks whether certain keys are pressed and changes the pitch. There are 3 sounds: beeps, boops and borps. Most keys boop, some of the command keys like Enter beep and just a few borp. I am considering adding a switch to turn off the speaker.<\/p>\n\n\n\n<p>I also found out that autorepeat works out of the box, as does the numlock functionality. It even picks up when I change the numlock state using my main keyboard. Not sure about how to get access to that info to set the numlock LED. Actually, that seems pretty straightforward too, because the keyboard class includes ways to get the status of the LEDs and use that to set physical LEDs on or off. I haven\u2019t hooked the LEDs up yet but I think I\u2019ve got the code all sorted.<\/p>\n\n\n\n<p>Originally written <a href=\"http:\/\/10.1.1.201\/index.php\/2025\/09\/29\/keypad-redux\/\">September 29, 2025<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was rooting around in my box of goodies the other day when I came across this old keypad and thought why not get it working? It\u2019s made from the numpad section of an old keyboard that I got when I cleared away all the old computers from a local [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":53,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"_links":{"self":[{"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=52"}],"version-history":[{"count":1,"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions\/54"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=\/wp\/v2\/media\/53"}],"wp:attachment":[{"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blinkbonnie.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}