import time
time.sleep(0.1) # Wait for USB to become ready
print("Hello, Pi Pico!")
from machine import Pin,PWM
ROW_PINS = [0, 1, 2, 3]
COL_PINS = [16,17,18,19]
row_pins = [Pin(pin, Pin.OUT) for pin in ROW_PINS]
col_pins = [Pin(pin, Pin.IN, Pin.PULL_DOWN) for pin in COL_PINS]
led = [Pin(28,Pin.OUT),Pin(27,Pin.OUT),Pin(22,Pin.OUT),Pin(21,Pin.OUT),Pin(14,Pin.OUT)]
print(f'row pin {row_pins}')
print(f'col pin {col_pins}')
keypad = [
['O', 'N', 'E', 'T'],
['W', 'H', 'R', 'F'],
['U', 'I', 'V', 'C'],
['*', '0', '#', 'D']
]
numbers=['ONE','TWO','THREE','FOUR','FIVE']
def scan_keypad():
for i in range(len(ROW_PINS)):
row_pins[i].value(1)
for j in range(len(COL_PINS)):
if col_pins[j].value() == 1:
return keypad[i][j]
row_pins[i].value(0)
return None
entered_password = ''
while True:
key = scan_keypad()
if key:
if key == '#':
print(entered_password)
for i in range(5):
if(entered_password==numbers[i]):
led[i].on()
time.sleep(2)
led[i].off()
entered_password=""
else:
entered_password += key
time.sleep(0.1)