Advertisement
Sandbird

Untitled

Jun 4th, 2016
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.34 KB | None | 0 0
  1. -- File: ds.lua --
  2. -- Paste bellow code to file --
  3.  
  4. local function toFahrenheit(c)
  5.     return c * 9 / 5 + 32
  6. end
  7.  
  8. t = require("ds18b20")
  9. -- GPIO0 is pin 3
  10. pin = 3
  11. lasttemp = 0
  12. t.setup(pin)
  13. temperature=t.read()
  14. lasttemp = temperature
  15. t1 = lasttemp / 10000
  16. tempout=(string.format("%2d", toFahrenheit(t1))
  17. print("Temperature: "..tempout.."'F")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement