forked from nitic04/Kobuki-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
48 lines (42 loc) · 1.43 KB
/
Copy pathindex.html
File metadata and controls
48 lines (42 loc) · 1.43 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Kobuki Control</title>
<script src="https://cdn.socket.io/4.0.1/socket.io.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var socket = io();
function sendCommand(command) {
if (socket.connected) {
socket.send(command);
} else {
console.error('WebSocket is not connected.');
}
}
document.getElementById('up').addEventListener('click', function() {
sendCommand('UP');
});
document.getElementById('down').addEventListener('click', function() {
sendCommand('DOWN');
});
document.getElementById('left').addEventListener('click', function() {
sendCommand('LEFT');
});
document.getElementById('right').addEventListener('click', function() {
sendCommand('RIGHT');
});
document.getElementById('stop').addEventListener('click', function() {
sendCommand('STOP');
});
});
</script>
</head>
<body>
<h1>Kobuki Control</h1>
<button id="up">Move Up</button>
<button id="down">Move Down</button>
<button id="left">Turn Left</button>
<button id="right">Turn Right</button>
<button id="stop">Stop</button>
</body>
</html>