lego11

PLC ascensore

Jun 27th, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. --Ascensore (C) lego11
  2. function clear()
  3. term.clear()
  4. term.setCursorPos(1, 1)
  5. print("PLC ASCENSORE (C) lego11 2018")
  6. print("")
  7. end
  8.  
  9. function sali()
  10. clear()
  11. print("Salita in corso")
  12. redstone.setOutput("right", true)
  13. sleep(0.2)
  14. redstone.setOutput("right", false)
  15. sleep(1)
  16. for i=1,22 do
  17. redstone.setOutput("right", true)
  18. sleep(0.2)
  19. redstone.setOutput("right", false)
  20. sleep(0.6)
  21. end
  22. end
  23.  
  24. function scendi()
  25. clear()
  26. print("Discesa in corso")
  27. redstone.setOutput("left", true)
  28. sleep(0.2)
  29. redstone.setOutput("left", false)
  30. sleep(1)
  31. for i=1,22 do
  32. redstone.setOutput("left", true)
  33. sleep(0.2)
  34. redstone.setOutput("left", false)
  35. sleep(0.6)
  36. end
  37. end
  38.  
  39. while true do
  40. clear()
  41. print("Attesa")
  42. os.pullEvent("redstone")
  43. if rs.getInput("bottom") = true then
  44. if rs.getInput("top") = true then
  45. sali()
  46. else
  47. scendi()
  48. end
  49. sleep(2)
  50. end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment