Guest User

control reles rpi computercraft

a guest
Jun 26th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. on = "sudo sh /home/pi/on"
  2. off = "sudo sh /home/pi/off"
  3. local old_s = redstone.getInput("left")
  4.  
  5. while true do
  6.   s = redstone.getInput("left")
  7.   if s ~= old_s then
  8.     old_s = s
  9.     if s == true then
  10.       http.post(
  11.                       "http://raspberrypi/mail/mail.php",
  12.                       "message="..textutils.urlEncode(tostring(on))
  13.       )
  14.     else
  15.       http.post(    
  16.                       "http://raspberrypi/mail/mail.php",  
  17.                       "message="..textutils.urlEncode(tostring(off))
  18.       )
  19.     end
  20.     redstone.setOutput("right", s)
  21.   end
  22.   sleep(0.5)
  23. end
Add Comment
Please, Sign In to add comment