Python Code for 3×4 Matrix Keypad with Raspberry Pi #piday #raspberrypi @Raspberry_Pi


Chris Crumpacker writes:

Another module of my alarm interface is done. I picked up a 3×4 matrix keypad from Adafruit (http://www.adafruit.com/products/419) But couldn’t find any good python code examples for it’s use. I was able to find a few examples that lead me down the right path in terms of scanning rows first as inputs and then swaping pins to scan the columns. I wrote two libraries, the first just uses 7 of the Raspberry Pi’s GPIO pins then I also wrote one that works for the MCP23008 chip since I’m really in a mode of saving pins when I can 🙂 Then also just wrote a demo script to show calling the libraries and their use.

Here is the code as it stands now, I have some ideas on how to change it to be better but this is fully working for now.

Check out the blog post with source code here!

Featured Adafruit Products


Membrane 3×4 Matrix Keypad + extras – 3×4 – Punch in your secret key into this numeric matrix keypad. This keypad has 12 buttons, arranged in a telephone-line 3×4 grid. It’s made of a thin, flexible membrane material with an adhesive backing (just remove the paper) so you can attach it to nearly anything. (read more)

998Each Friday is PiDay here at Adafruit, be sure to check out our posts, tutorials and new Raspberry Pi related products. Have you tried the new “Adafruit Raspberry Pi Educational Linux Distro”? It’s our tweaked distribution for teaching electronics using the Raspberry Pi. But wait, there’s more! Try our new Raspberry Pi WebIDE! The easiest way to learn programming on a Raspberry Pi.

We now have Raspberry Pi Model B with 512MB RAM in stock and shipping now!

Make a robot friend with Adafruit’s CRICKIT – A Creative Robotics & Interactive Construction Kit. It’s an add-on to our popular Circuit Playground Express, FEATHER and other platforms to make and program robots with CircuitPython, MakeCode, and Arduino. Start controlling motors, servos, solenoids. You also get signal pins, capacitive touch sensors, a NeoPixel driver and amplified speaker output. It complements & extends your boards so you can still use all the goodies on the microcontroller, now you have a robotics playground as well.

Join 7,500+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython in 2018 – Python on Microcontrollers is here!

Have an amazing project to share? Join the SHOW-AND-TELL every Wednesday night at 7:30pm ET on Google+ Hangouts.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Follow Adafruit on Instagram for top secret new products, behinds the scenes and more https://www.instagram.com/adafruit/

Maker Business — Fewer startups, and other collateral damage from the 2018 tariffs

Wearables — Light as a Worbla feather

Electronics — How to make your own magnetic field probe!

Biohacking — The State of DNA Analysis in Three Mindmaps

Python for Microcontrollers — One year of CircuitPython weeklies!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !

No Comments

No comments yet.

Sorry, the comment form is closed at this time.