tuekats

energyReading

Jul 5th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. local modem = peripheral.wrap("back")
  2. local hystMem = 0
  3. local limitLow = 50
  4. local limitHigh = 95
  5. local outputSide = "top"
  6.  
  7. while true do
  8.  
  9. modem.open(1)
  10. local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  11. modem.closeAll()
  12. print("energy reading was: "..message)
  13. local energy = message
  14. if energy < limitLow then
  15. redstone.setOutput(outputSide,false)
  16. hystMem = 0
  17. end
  18. if (energy >= limitLow) and (energy <= limitHigh) then
  19. if hystMem == 0 then redstone.setOutput(outputSide,false) end
  20. if hystMem == 1 then redstone.setOutput(outputSide,true) end
  21.  
  22. end
  23. if energy > limitHigh then
  24. redstone.setOutput(outputSide,true)
  25. hystMem = 1
  26. end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment