-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
42 lines (38 loc) · 920 Bytes
/
index.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
<!doctype html>
<html>
<head>
<title>Arduino to Node to Front end JS</title>
<style>
#light {
margin: 100px;
width: 20px;
height: 20px;
background: red;
border-radius: 100%;
}
#light.on {
background: blue;
box-shadow: 0 0 10px blue;
}
</style>
</head>
<body id="body">
<div id="light"></div>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>
$(function () {
var socket = io();
// Click for writing to Arduino
$('#light').click(function() {
socket.emit('screenPress');
})
// Listen for message from Arduino
socket.on('press', function(msg){
console.log('press');
$("#light").toggleClass('on');
});
});
</script>
</body>
</html>