You are reading a single comment by @patmolloy and its replies. Click here to read the full conversation.
  • Well, something magical has happen on 1.63 Wiznet .. this code now works perfectly ! I can switch the onboard leds on and off from a little web page !

    E.enableWatchdog(10);
    
    var eth = require("WIZnet").connect();
    eth.setIP({ ip : "192.168.254.248" });
    eth.setIP({ dns : "208.67.222.222" });
    eth.setIP({ gateway: "192.168.254.100" });
    
    
    function onPageRequest(req, res) {
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.write('<html><body>');
      res.write('<p>Button is '+(BTN.read()?'on':'off')+'</p>');
      res.write('<p>Turn LED1 <a href="/on1">on</a> or <a href="/off1">off</a></p>');
      res.write('<p>Turn LED2 <a href="/on2">on</a> or <a href="/off2">off</a></p>');
      res.write('<p>Turn LED3 <a href="/on3">on</a> or <a href="/off3">off</a></p>');
      res.end('</body></html>');
      if (req.url=="/on1") digitalWrite(LED1, 1);
      if (req.url=="/off1") digitalWrite(LED1, 0);
      if (req.url=="/on2") digitalWrite(LED2, 1);
      if (req.url=="/off2") digitalWrite(LED2, 0);
      if (req.url=="/on3") digitalWrite(LED3, 1);
      if (req.url=="/off3") digitalWrite(LED3, 0);
    }
    
    require("http").createServer(onPageRequest).listen(80);
    
    
    
About

Avatar for patmolloy @patmolloy started