Advertisement
Guest User

pression

a guest
Jul 24th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. local pressMax = 4.5
  2. w, h = term.getSize()
  3.  
  4. comp = "left"
  5. lpr = "back"
  6.  
  7. function centerprint(text, line)
  8.   term.setCursorPos((w-string.len(text))/2, line)
  9.   term.write(text)
  10. end
  11.  
  12. function printScreen()
  13.   term.clear()
  14.   centerprint("SyståA8me de pression", 1)
  15.   term.setCursorPos(1,2)
  16.   print("Pression actuelle : "..actualPress)
  17.   print("Pression souhaitåA9e ; "..pressMax)
  18.   if actualPress >= pressMax then
  19.     Working = "Non"
  20.   else
  21.     Working = "Oui"
  22.   end
  23.   print("Fonctionne : "..Working)
  24. end
  25.  
  26. function main()
  27.   while true do
  28.     actualPress = rs.getAnalogInput(lpr)/2
  29.     if actualPress < pressMax then
  30.       rs.setOutput(comp,true)
  31.       -- rs.setOutput("front",true)
  32.     else
  33.       -- rs.setOutput("front",false)
  34.       rs.setOutput(comp,false)
  35.     end
  36.   printScreen()
  37.   sleep(1)
  38.   end
  39. end
  40.  
  41. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement