Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --IO index ESP8266 pin IO index ESP8266 pin
- --0 [*] GPIO16 7 GPIO13
- --1 GPIO5 8 GPIO15
- --2 GPIO4 9 GPIO3
- --3 GPIO0 10 GPIO1
- --4 GPIO2 11 GPIO9
- --5 GPIO14 12 GPIO10
- --6 GPIO12
- --pk1=6 --led zielona
- --pk2=8 --led czerwona
- --pk3=7 --led niebieska
- pk4=1
- pwm1=6 --LED ZIELONA
- pwm.setup(pwm1, 500, 512)
- pwm2=8 --LED CZERWONA
- pwm.setup(pwm2, 500, 512)
- pwm3=7 --LED NIEBIESKA
- pwm.setup(pwm3, 500, 512)
- --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);
- zmpom1=0
- zmpom2=0
- zmpom3=0
- value=0
- uart.setup(0,9600,8,0,1)
- --==========================================
- print("Teraz skanuje adresy IP:")
- wifi.setmode(wifi.STATION)
- wifi.sta.config("SALA44","S@la44CkP");
- wifi.sta.setip({ip="192.168.44.106", netmask="255.255.255.0", gateway="192.168.44.1"})
- print("Konfiguracja skonczona, IP jest : "..wifi.sta.getip())
- tmr.delay(1000000)
- --==========================================
- sv = net.createServer(net.TCP, 30)
- function receiver(sck, data)
- --data=string.match(data,'GET /%s-..*%sHTTP/')
- 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.HIGH) end
- if (str=="led2") then print("LED2") gpio.write(pk1,gpio.LOW) 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") gpio.write(pk2,gpio.LOW)end
- if (str=="led6") then print("LED6") gpio.write(pk2,gpio.HIGH)end
- if (str=="led10") then print("pwm1") sciemnianie(1)end
- if (str=="led11") then print("pwm1") sciemnianie(2)end
- if (str=="led12") then print("pwm2") sciemnianie(3)end
- if (str=="led13") then print("pwm2") sciemnianie(4)end
- if (str=="led14") then print("pwm3") sciemnianie(5)end
- if (str=="led15") then print("pwm3") sciemnianie(6)end
- if (str=="exit") then file.remove("init.lua") end
- str=" "
- sck:close()
- end
- if sv then
- sv:listen(80, function(conn)
- conn:on("receive", receiver)
- conn:send("hello")
- end)
- end
- --============================================================================================
- uart.on("data", "\r",
- function(data)
- print(recvdata)
- end, 0)
- --=====================================================================================
- function sciemnianie(szybkosc)
- if (szybkosc==1) then
- value=zmpom1
- if (value<500) then value=value+20 end
- pwm.setduty(pwm1, value)
- zmpom1=value
- end
- if (szybkosc==2) then
- value=zmpom1
- if(value>0) then value=value-20 end
- pwm.setduty(pwm1, value)
- zmpom1=value
- end
- if (szybkosc==3) then
- value=zmpom2
- if (value<500) then value=value+20 end
- pwm.setduty(pwm2, value)
- zmpom2=value
- end
- if (szybkosc==4) then
- value=zmpom2
- if(value>0) then value=value-20 end
- pwm.setduty(pwm2, value)
- zmpom2=value
- end
- if (szybkosc==5) then
- value=zmpom3
- if (value<500) then value=value+20 end
- pwm.setduty(pwm3, value)
- zmpom3=value
- end
- if (szybkosc==6) then
- value=zmpom3
- if(value>0) then value=value-20 end
- pwm.setduty(pwm3, value)
- zmpom3=value
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement