-
Notifications
You must be signed in to change notification settings - Fork 0
/
RemoteEsp01RCar.html
56 lines (55 loc) · 1.49 KB
/
RemoteEsp01RCar.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Remote Control RC</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
}
.button {
display: inline-block;
margin: 13px;
padding: 10px 20px;
font-size: 15px;
cursor: pointer;
border-radius: 5px;
background-color: #3498db;
color: white;
text-decoration: none;
}
.button:hover {
background-color: #2980b9;
}
</style>
</head>
<body>
<h1>Remote Control RC</h1>
<div>
<button class="button" onclick="sendCommand('forward')">Maju</button>
</div>
<div>
<button class="button" onclick="sendCommand('left')">Kiri</button>
<button class="button" onclick="sendCommand('stop')">Stop</button>
<button class="button" onclick="sendCommand('right')">Kanan</button>
</div>
<div>
<button class="button" onclick="sendCommand('reverse')">Mundur</button>
</div>
<script>
function sendCommand(command) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log("Command sent: " + command);
}
};
xhttp.open("POST", "http://192.168.4.1:80/motor", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("command=" + command);
}
</script>
</body>
</html>