Advertisement
chg1730

REAL TIME CLOCK

Mar 31st, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. mod = peripheral.wrap("right")
  2. mod.open(0)
  3. mon = peripheral.wrap("top")
  4. mon.setTextColor(colors.cyan)
  5.     local function getDate()
  6.     local request = http.get("http://www.timeapi.org/cet/now?format=%20%25I:%25M:%25S")
  7.     if request then
  8.         local date = request.readAll()
  9.         request.close()
  10.         return date
  11.     else
  12.         return nil
  13.         end
  14.     end
  15.  
  16. while true do
  17. id,message = os.pullEvent("modem_message")
  18. datum = getDate(date)
  19. if datum then
  20. mon.setTextColor(colors.cyan)
  21. mon.setCursorPos(14,11)
  22. mon.write(datum)
  23. else
  24. mon.setCursorPos(14,11)
  25. mon.setTextColor(colors.red)
  26. mon.write("TIMED OUT")
  27. end
  28. end
  29. sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement