Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- keypad = require("component").os_keypad
- event = require("event")
- local pin = "1234"
- local keypadInput = ""
- function checkPin()
- if keypadInput == pin then
- keypad.setDisplay("Pass", 2)
- else
- keypad.setDisplay("Wrong", 4)
- end
- keypadInput = ""
- os.sleep(1) -- Enforce a small delay to keep text for a short time
- end
- function keypadEvent(eventName, address, button, label)
- if button == 10 then -- Is it del
- keypadInput = string.sub(keypadInput, 1, -2) -- Del last char
- elseif button == 12 then
- checkPin()
- else
- keypadInput = keypadInput .. button_label
- end
- keypad.setDisplay(keypadInput, 7)
- end
- event.listen("keypad", keypadEvent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement