Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pk1=0
- pk2=1
- pk3=2
- pk4=3
- gpio.mode(pk1, gpio.OUTPUT);
- gpio.mode(pk2, gpio.OUTPUT);
- gpio.mode(pk3, gpio.OUTPUT);
- gpio.mode(pk4, gpio.OUTPUT);
- gpio.write(pk1,gpio.LOW);
- gpio.write(pk2,gpio.LOW);
- gpio.write(pk3,gpio.LOW);
- gpio.write(pk4,gpio.LOW);
- uart.setup(0,9600,8,0,1)
- --==========================================
- print("Teraz skanuje adresy IP:")
- AP_CFG={}
- AP_CFG.ssid="misiumisiu1"
- AP_CFG.pwd="123456789"
- AP_CFG.hidden = 0
- AP_CFG.max=4
- AP_CFG.beacon=100
- AP_IP_CFG={}
- AP_IP_CFG.ip="192.168.4.1"
- AP_IP_CFG.netmask="255.255.255.0"
- AP_IP_CFG.gateway="192.168.4.1"
- AP_DHCP_CFG ={}
- AP_DHCP_CFG.start = "192.168.4.2"
- wifi.setmode(wifi.SOFTAP)
- wifi.ap.config(AP_CFG)
- wifi.ap.setip(AP_IP_CFG)
- wifi.ap.dhcp.config(AP_DHCP_CFG)
- wifi.ap.dhcp.start();
- print(wifi.ap.getip());
- tmr.delay(1000000)
- tmr.alarm(0, 2000, tmr.ALARM_AUTO, function()
- for mac,ip in pairs(wifi.ap.getclient()) do
- print(mac,ip)
- if (ip=="192.168.4.2") then
- print("Pilot ok "..ip);
- tmr.stop(0);
- end
- end
- end)
- sv = net.createServer(net.TCP, 30)
- function receiver(sck, data)
- str = string.sub(data,string.find(data,"GET /")
- +5,string.find(data,"HTTP/")-2)
- print(str)
- if (str=="led1") then print("led1")
- gpio.write(pk1,gpio.LOW) end
- if (str=="led2") then print("led2")
- gpio.write(pk1,gpio.HIGH) end
- if (str=="led3") then print("led3")
- gpio.write(pk2,gpio.LOW) end
- if (str=="led4") then print("led4")
- gpio.write(pk2,gpio.HIGH) end
- if (str=="led5") then print("led5")end
- if (str=="led6") then print("led6")end
- if (str=="led7") then print("led7")end
- if (str=="led7") then print("led7")end
- if (str=="exit") then file.remove("init.lua") end
- sck:close()
- end
- if sv then
- sv:listen(80, function(conn)
- conn:on("receive", receiver)
- conn:send("Witaj przybyszu")
- end)
- end
- uart.on("data", "\r",
- function(data)
- print(recvdata)
- end, 0)
- function sciemnianie(szybkosc)
- if(szybkosc==1)then
- if(val<500)then val=val+20 end
- pwm.setduty(pwm2, val)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement