MrDj200

PressureControl

Dec 12th, 2014
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. --MrDj 2014
  2.  
  3. screen = true --set to "true" if you have a screen and to "false" if not
  4. screenSide = "top"
  5.  
  6. valveSide = "bottom"
  7. outSide = "back"
  8. valve=peripheral.wrap(valveSide)
  9.  
  10.  
  11. function Screen(crnt, side)
  12.     if screen == true then
  13.         mon=peripheral.wrap(side)
  14.         mon.clear()
  15.         mon.setCursorPos(1, 1)
  16.         mon.write(crnt)
  17.     else
  18.         --nothin :)
  19.     end
  20. end
  21.  
  22. function off()
  23.     rs.setOutput(outSide, true)
  24. end
  25.  
  26. function on()
  27.     rs.setOutput(outSide, false)
  28. end
  29.  
  30. while true do
  31.     current = valve.getPressure()
  32.     max = valve.getDangerPressure()
  33.     myMax = max - 0.1
  34.     Screen(current, screenSide)
  35.     shell.run("clear")
  36.     print("Current Pressure: "..current)
  37.     sleep(1)
  38.     while current>=myMax do
  39.         current = valve.getPressure()
  40.         off()
  41.         rs.setOutput(valveSide, true)
  42.         print("Current Pressure: "..current)
  43.         print("Releasing air!")
  44.         sleep(.25)
  45.         shell.run("clear")
  46.     end
  47.     on()
  48.     rs.setOutput(valveSide, false)
  49. end
Advertisement
Add Comment
Please, Sign In to add comment