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_UP) 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)]
keypad = [
['1', '2', '3', 'A'],
['4', '5', '6', 'B'],
['7', '8', '9', 'C'],
['*', 0, '#', 'D']
]
numbers=['1' , '2' , '3' , '4' , '5']
def scan_keypad():
key_pressed = None
for i, row in enumerate(row_pins):
row.value(0)
for j, col in enumerate(col_pins):
if not col.value():
key_pressed = keypad[i][j]
while not col.value():
pass
row.value(1)
return key_pressed
entered_password = ""
while True:
key = scan_keypad()
if key is not None:
print("Key pressed:", 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)