<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" c initial-scale=1.0" />
<title>NodeMCU Car Remote</title>
<style>
.btn {
display: inline-block;
margin: 10px;
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>NodeMCU Car Remote</h1>
<div>
<button
class="btn"
>
Forward
</button>
<button
class="btn"
>
Backward
</button>
</div>
<div>
<button
class="btn"
>
Left
</button>
<button
class="btn"
>
Right
</button>
</div>
<div>
<button class="btn" >Turn on White LED</button>
<button class="btn" >
Turn off White LED
</button>
<button class="btn" >Turn on Red LED</button>
<button class="btn" >
Turn off Red LED
</button>
</div>
[removed]
var timer;
function sendCommand(command) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
console.log("Command sent: " + command);
}
};
xhttp.open("GET", "http://192.168.4.1/?State=" + command, true);
xhttp.send();
}
function stopCommand() {
clearTimeout(timer);
timer = setTimeout(function () {
sendCommand("S");
}, 500);
}
function turnOnLED(ledCommand) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
console.log("LED turned on: " + ledCommand);
}
};
xhttp.open("GET", "http://192.168.4.1/?State=" + ledCommand, true);
xhttp.send();
}
function turnOffLED(ledCommand) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
console.log("LED turned off: " + ledCommand);
}
};
xhttp.open("GET", "http://192.168.4.1/?State=" + ledCommand, true);
xhttp.send();
}
[removed]
</body>
</html>
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}