I am using ESP8266-01.
The LED is connected to GPIO2
The original example can be found here:
https://github.com/esp8266-espruino/esp ... 07-Samples
ESP8266WiFi.init();
var ipInfo = ESP8266WiFi.getIPInfo();
print("Current IP address is: " + ESP8266WiFi.getAddressAsString(ipInfo.ip));
var GPIO2 = new Pin(2);
var http = require("http");
var httpSrv = http.createServer(function(request, response) {
print(process.memory());
response.write("<html><body>");
if (request.url == "/on") {
response.write("<b>LED os on</b>");
digitalWrite(GPIO2, true);
print ("led on");
} else if (request.url == "/off") {
response.write("<b>LED os off</b>");
print ("led off");
digitalWrite(GPIO2, false);
} else {
response.write("Welcome to ESP with JS");
}
response.end("<br><a href='/on'>Led ON</a><br><a href='/off'>Led OFF</a></body></html>");
});
httpSrv.listen(80);