Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. LED On & OFF Problem

LED On & OFF Problem

Scheduled Pinned Locked Moved My Project
1 Posts 1 Posters 977 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Emaly
    wrote on last edited by
    #1

    Hi All.
    my code doesn't work i don't know why what is the problem can some one help me please many thanks for your help. using ESP12E with Lua.

    wifi.setmode(wifi.STATION)
    wifi.sta.config("SSID","PASS")

    print(wifi.sta.getip())
    gpio.mode(2, gpio.OUTPUT)

    srv = net.createServer(net.TCP, 1)
    srv:listen(80,function(conn)
    conn:on("receive", function(conn,request)

        local buf = "";
        local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
        if(method == nil)then
            _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
        end
        
        local _GET = {}
        if (vars ~= nil)then
            for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
                _GET[k] = v
            end
        end
    
        --print (_GET)
        
        buf = buf.."<h1> Web Server 87</h1>";
        buf = buf.."<p>LIGHT  <a href=\"?pin=ON\"><button>ON</button></a>&nbsp;<a href=\"?pin=OFF\"><button>OFF</button></a></p>";
    
        local _on,_off = "",""
        
        
        conn:send(buf);
        print(_GET.pin)
        print('Pin 2 is:' .. gpio.read(2))
        action(_GET.pin)
    
       
    end)
    conn:on("sent",function(conn) conn:close() end)
    

    end)
    function action(param)

        gpio.write(2, gpio.HIGH);
    elseif(param == "OFF" ) then
      
        gpio.write(2, gpio.LOW);
    end
    

    end

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    15

    Online

    11.7k

    Users

    11.2k

    Topics

    113.1k

    Posts


    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • MySensors
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular