Amend micropython code to be called by VB code
Posted: Tue Dec 05, 2017 3:05 am
Hi, does anyone know how to amend the following code to be activated by some VB script on another pc (on the same network) rather than having to be a button press on a webpage?
The ESP is setup to trigger an Arduino which in turn sends a key press via USB.
The code I have so far is
The code I am wishing to use to activate the code above (as amended) is
Thanks.
Alex
The ESP is setup to trigger an Arduino which in turn sends a key press via USB.
The code I have so far is
Code: Select all
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","WiFipassword")
print(wifi.sta.getip())
pin_out = 3
US_TO_MS = 1000
gpio.mode(pin_out, gpio.OUTPUT)
gpio.write(pin_out, gpio.HIGH)
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,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
buf = buf.."<h1> ESP8266 Web Server</h1>";
buf = buf.."<p>GPIO0 <a href=\"?pin=SND\"><button>Send Key</button></a></p>";
local _on,_off = "",""
if(_GET.pin == "SND")then
gpio.write(pin_out, gpio.HIGH);
tmr.delay(200 * US_TO_MS);
gpio.write(pin_out, gpio.LOW);
end
client:send(buf);
client:close();
collectgarbage();
end)
end)
The code I am wishing to use to activate the code above (as amended) is
Code: Select all
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("http://IP-of-Ardduino/send-pageup-to-laptop")
Thanks.
Alex