Skip to content

Instantly share code, notes, and snippets.

@Shashi18
Last active February 28, 2018 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shashi18/c14391476321fc1514da1c510a5e37ce to your computer and use it in GitHub Desktop.
Save Shashi18/c14391476321fc1514da1c510a5e37ce to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, height=device-height">
<script>
var con;
function web(){
con = new WebSocket('ws://192.168.1.5:81/',['arduino']);
con.onopen = function(event){
console.log("Opened");
};
con.onmessage = function (evt) {
var received_msg = evt.data;
document.getElementById("message").innerHTML = evt.data;
};
con.onclose = function(){
console.log("Masakaaaa!!!");
};
}
function SwitchON() {
var toSend = "ON";
con.send(toSend);
};
function SwitchOFF() {
var toSend = "OFF";
con.send(toSend);
};
</script>
</head>
<body style="height=100% width=100%">
Wemos D1 Mini SBC Bot<p></p>
<input type="button" onclick="SwitchON()"> Turn LED Off<p></p>
<input type="button" onclick="SwitchOFF()"> Turn LED On <p></p>
<textarea id="message"></textarea>
<input type="button" value="Click to Connect" onclick="web()">
<input type="button" value="Click to Stop" onclick="sto()">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment