Ledger Nano X - The secure hardware wallet
SHARE
TWEET

a

a guest Apr 5th, 2020 140 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component, sides, event = require("component"), require("sides"), require("event")
  2.  
  3. local k,r = component.os_keypad, component.redstone
  4. local cc,c = "","1234"
  5.  
  6. customText = {"1","2","3","4","5","6","7","8","9","CL","0","OK"}
  7. customColor = {15,15,15,15,15,15,15,15,15,15,15,15}
  8. k.setKey(customText,customColor)
  9.  
  10. r.setOutput(sides.back, 0)
  11.  
  12. function checkCode()
  13.   if (cc == c) then
  14.     k.setDisplay("Granted", 2)
  15.     cc = ""
  16.     r.setOutput(sides.back, 15)
  17.     os.sleep(5)
  18.     r.setOutput(sides.back, 0)
  19.   else
  20.     k.setDisplay("Denied", 4)
  21.     cc = ""
  22.     os.sleep(2)
  23.   end
  24.   k.setDisplay("")
  25. end
  26.  
  27. function updateDisplay()
  28.   local display = ""
  29.   for i=1, #cc do
  30.     display = display .. "*"
  31.   end
  32.   k.setDisplay(display, 15)
  33. end
  34.  
  35. function keyPressed(eventName, address, button, buttonLabel)
  36.   if (buttonLabel == "CL") then
  37.     cc = ""
  38.   elseif (buttonLabel == "OK") then
  39.     checkCode()
  40.   else
  41.     cc = cc..buttonLabel
  42.   end
  43.  
  44.   updateDisplay()
  45. end
  46.  
  47. event.listen("keypad",keyPressed)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top