Esempio n. 1
0
# List with secret keycode (Hey, that's the same code as my luggage!)
code = ['1', '2', '3', '4']

# List for user input
guess = []

# Number of tries
count = 0

#
# Create bus object using our board's I2C port
i2c = busio.I2C(board.SCL, board.SDA)

# Create relay object
keypad = sparkfun_qwiickeypad.Sparkfun_QwiicKeypad(i2c)

print('Qwicc Keypad Example 6 Key Code')

# Check if connected
if keypad.connected:
    print('Keypad connected. Firmware: ', keypad.version)
else:
    print('Keypad does not appear to be connected. Please check wiring.')
    exit()

print('Type the correct Keycode or Ctrl-C to exit program.')
print('Please type in the correct 4 digit Keycode.')

try:
    while True:
Esempio n. 2
0
    try:
        # check to see if hex or decimal arguement
        if '0x' in sys.argv[1]:
            i2c_address = int(sys.argv[1], 16)
        else:
            i2c_address = int(sys.argv[1])
    except ValueError:
        print('Ignoring invalid arguement: ' + str(sys.argv[1]))

# Show the initial address
print('Current i2c address = ' + str(i2c_address) + ' [' + hex(i2c_address) +
      ']')

# Create library object using our Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)
keypad = sparkfun_qwiickeypad.Sparkfun_QwiicKeypad(i2c, i2c_address)

if keypad.connected:
    print('Qwiic Keypad Example.')
else:
    # if we can't connecct, something is wrong so just quit
    print('Keypad does not appear to be connected. Please check wiring.')
    exit()

print('Address: ' + str(i2c_address) + ' [' + hex(i2c_address) + ']')

text = input(
    'Enter a new I2C address (as a decimal from 8 to 119 or hex 0x08 to 0x77):'
)

# check to see if hex or decimal value