Advertisement
TeoremaPi

Directo 2 Receptor

Nov 30th, 2020
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. -- guardamos la pantalla del ordenador, el monitor y el flux gate
  2. c = term.current();                 -- computer
  3. m = peripheral.wrap("top")          -- monitor
  4. f = peripheral.wrap("flux_gate_2")  -- flux gate
  5.  
  6. -- iniciamos el wifi
  7. rednet.open( "right" )
  8.  
  9. -- limpiamos la pantalla
  10. function limpiarPantalla()
  11.     m.setBackgroundColor(colors.black)
  12.     m.clear()
  13.     m.setTextScale(1)
  14.     m.setCursorPos(2,2)
  15.     m.write('Estado: ')
  16. end
  17.  
  18. while true do    
  19.     -- esperamos que llegue un mensaje
  20.     senderId, message, protocol = rednet.receive(1)
  21.    
  22.     if message == 'on' then
  23.         -- si llega el mensaje de encender
  24.         f.setSignalLowFlow(100)
  25.  
  26.         limpiarPantalla()
  27.         m.blit('ON', 'ff', 'dd')
  28.  
  29.     elseif message == 'off' then
  30.         -- si llega el mensaje de apagar
  31.         f.setSignalLowFlow(0)
  32.  
  33.         limpiarPantalla()
  34.         m.blit('OFF', 'fff', 'eee')
  35.     end
  36.  
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement