Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --WIRING DIAGRAM (use rednet cables and color them accordingly)
- -- **Looking from back of display**
- --
- -- {Lime} {Brown}
- -- {White} {Yellow} {DkGray} {DkBlue}
- -- {Salmon} {DkGreen}
- -- {Orange} {LtBlue} {LtGray} {Purple}
- -- {Pink} {Cyan}
- --
- os.loadAPI("json") --load api for reading JSON
- uni = { --array of units
- 63, --0
- 3, --1
- 109, --2
- 103, --3
- 83, --4
- 118, --5
- 126, --6
- 35, --7
- 127, --8
- 115, --9
- }
- dec = { --array of decimals
- 8064, --0
- 384, --1
- 13952, --2
- 13184, --3
- 10624, --4
- 15104, --5
- 16128, --6
- 4480, --7
- 16256, --8
- 14720, --9
- }
- prs = { --array of sums
- }
- k=0
- for j = 1, 10 do --populate prs array
- for i = 1, 10 do
- prs[k] = uni[i]+dec[j]
- k=k+1
- end
- end
- --lightOn = 1 --starting value of blinking colon
- while true do
- http.request("http://worldtimeapi.org/api/timezone/America/New_York") --aquire time (JSON)
- --********Change the URL to your own time zone
- while true do
- evt, url, msg = os.pullEvent() --if website returns a result then
- if evt == "http_success" then
- str = msg.readAll() --read data from website
- obj = json.decode(str) --decode JSON
- value = obj.datetime --store time value string
- local time = value
- local hdot = string.sub (time, 12, 13) --pull hours from string
- local mdot = string.sub (time, 15, 16) --pull minutes from string
- h = tonumber(hdot) --convert to integer
- m = tonumber(mdot) --''
- if h >= 13 then --*****If you want 24 hour format,
- h = h-12 -- comment *****
- end -- out ******
- if h == 0 then -- these ******
- h = 12 -- 6 ******
- end -- lines. ******
- break
- elseif evt == "http_failure" then --if no signal print no connection
- print("No connection")
- break
- end
- end
- if h ~= nil then --if hour value /= nil, output value
- rs.setBundledOutput("left", prs[h])
- end
- if m ~= nil then --if minute value /= nil, output value
- rs.setBundledOutput("right", prs[m])
- end
- -- rs.setBundledOutput("top", lightOn) --set colon on
- -- if lightOn == 1 then
- -- lightOn = 0
- -- else
- -- lightOn = 1
- -- end
- sleep(10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement