-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·36 lines (21 loc) · 845 Bytes
/
index.html
File metadata and controls
executable file
·36 lines (21 loc) · 845 Bytes
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
<!doctype html>
<html>
<head>
<title>Communicating from Node.js to an Arduino</title>
<script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js'></script>
</head>
<body>
<h1>Communicating from Node.js to an Arduino</h1>
<button id="lightOn">Turn Light On</button>
<button id="lightOff">Turn Light Off</button>
<script>
var socket = io();
document.getElementById('lightOn').onclick = function() {
socket.emit('lights', { "status":"1" });
};
document.getElementById('lightOff').onclick = function(){
socket.emit('lights', { "status":"0" });
};
</script>
</body>
</html>