Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Security Program Help
#1
Not sure how to properly differentiate code between normal talk on here. New to the site, please bear with me. I do appreciate tips and advice if given.I am new to coding, currently taking a programming class. This is a personal project i thought would be fun.

I am working on a security program using a 4x4 matrix keypad w/RPi3. The keypad is not a membrane style, it is more like the old landline phones with white plastic buttons.

From what I can gather, based on what I have learned in class, i will also need an if/else loop or two.

Code:

import RPi.GPIO

GPIO.setmode(GPIO.BCM)

#Set Keypad Layout
Keypad = [
[1, 2, 3, "A"],
[4, 5, 6, "B"],
[7, 8, 9, "C"],
[0, "F", "E", "D"]
]
#Keypad -> GPIO Pin Out
#BCM Numbering
COL_PINS = [4, 17, 22, 27]
ROW_PINS = [18, 25, 5, 6]

#example keypad entered code
#CODE = A12345

factory = rpi_gpio.KeypadFactory()

# Try factory.create_4_by_3_keypad
# and factory.create_4_by_4_keypad for reasonable defaults
keypad = factory.create_keypad(keypad=KEYPAD, row_pins=ROW_PINS, col_pins=COL_PINS)

def printKey(key):
print(key)

# printKey will be called each time a keypad button is pressed
keypad.registerKeyPressHandler(printKey)

Code End
Reply


Messages In This Thread
Security Program Help - by Python_n00b_06 - Nov-05-2017, 05:01 AM
RE: Security Program Help - by sparkz_alot - Nov-05-2017, 04:05 PM
RE: Security Program Help - by Python_n00b_06 - Mar-02-2018, 12:30 AM
RE: Security Program Help - by Python_n00b_06 - Mar-02-2018, 05:51 PM
RE: Security Program Help - by Python_n00b_06 - Mar-04-2018, 06:39 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020