Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wifi.setmode(wifi.STATION)
- wifi.sta.config("ИмяСетиВайФай","ПарольОтВайфай")
- local pin = 4 --> GPIO2
- function debounce (func)
- local last = 0
- local delay = 400000
- return function (...)
- local now = tmr.now()
- if now - last < delay then return end
- last = now
- return func(...)
- end
- end
- function onChange ()
- print('The pin value has changed to '..gpio.read(pin))
- conn=net.createConnection(net.TCP, 0)
- conn:on("receive", function(conn, payload) print(payload) end)
- conn:connect(80,'23.23.215.91')
- conn:send("GET /trigger/button_pressed/with/key/ВашКлюч HTTP/1.1\r\n")
- conn:send("Host: maker.ifttt.com\r\n")
- conn:send("Accept: */*\r\n")
- conn:send("User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n")
- conn:send("\r\n")
- end
- gpio.mode(pin, gpio.FLOAT)
- gpio.write(pin, gpio.LOW)
- gpio.trig(pin, 'both', debounce(onChange))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement