Пример #1
0
#!/usr/bin/python

#Select which IO version by commenting the unused version 
from matrixKeypad_MCP230xx import keypad
#from matrixKeypad_RPi_GPIO import keypad

from time import sleep
from sys import exit
 
# Initialize the keypad class. Using the **optional** variable to change it to a 4x4 keypad
kp = keypad(columnCount = 4)

# Setup variables
attempt = "0000"
passcode = "1912"
count = 0

# Loop while waiting for a keypress
while True:
	# Loop to get a pressed digit
	digit = None
	while digit == None:
		digit = kp.getKey()
 
	# Print the result
	print "Digit Entered:       %s"%digit
	attempt = (attempt[1:] + str(digit))  
	print "Attempt value:       %s"%attempt
	
	# Check for passcode match
	if (attempt == passcode):
Пример #2
0
#!/usr/bin/python

from matrixKeypad_MCP230xx import keypad
#from matrixKeypad_RPi_GPIO import keypad
from time import sleep

# Initialize the keypad class
kp = keypad()


def digit():
    # Loop while waiting for a keypress
    r = None
    while r == None:
        r = kp.getKey()
    return r


print "Please enter a 4 digit code: "

# Getting digit 1, printing it, then sleep to allow the next digit press.
d1 = digit()
print d1
sleep(1)

d2 = digit()
print d2
sleep(1)

d3 = digit()
print d3
Пример #3
0
#!/usr/bin/python
 
from matrixKeypad_MCP230xx import keypad
#from matrixKeypad_RPi_GPIO import keypad
from time import sleep
 
# Initialize the keypad class
kp = keypad()
 
def digit():
    # Loop while waiting for a keypress
    r = None
    while r == None:
        r = kp.getKey()
    return r 
 
print "Please enter a 4 digit code: "
 
# Getting digit 1, printing it, then sleep to allow the next digit press.
d1 = digit()
print d1
sleep(1)
 
d2 = digit()
print d2
sleep(1)
 
d3 = digit()
print d3
sleep(1)
 
Пример #4
0
#!/usr/bin/python

#Select which IO version by commenting the unused version
from matrixKeypad_MCP230xx import keypad
#from matrixKeypad_RPi_GPIO import keypad

from time import sleep
from sys import exit

# Initialize the keypad class. Using the **optional** variable to change it to a 4x4 keypad
kp = keypad(columnCount=4)

# Setup variables
attempt = "0000"
passcode = "1912"
count = 0

# Loop while waiting for a keypress
while True:
    # Loop to get a pressed digit
    digit = None
    while digit == None:
        digit = kp.getKey()

    # Print the result
    print "Digit Entered:       %s" % digit
    attempt = (attempt[1:] + str(digit))
    print "Attempt value:       %s" % attempt

    # Check for passcode match
    if (attempt == passcode):