-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPIR_Control_LED.html
More file actions
43 lines (40 loc) · 1.21 KB
/
PIR_Control_LED.html
File metadata and controls
43 lines (40 loc) · 1.21 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>PIR Control LED</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://webduino.io/components/webduino-js/dist/webduino-all.min.js"></script>
<script src="https://blockly.webduino.io/webduino-blockly.js"></script>
<script src="https://blockly.webduino.io/lib/runtime.min.js"></script>
<style>
#light img {height: 200px; display: none;}
#light.off #light_off, #light.on #light_on {display: inline-block;}
</style>
</head>
<body>
<div id="light" class="off">
<img src="../image/light-off.jpg" id="light_off">
<img src="../image/light-on.jpg" id="light_on">
</div>
<script>
var pir, led;
var light = document.getElementById("light");
boardReady({device: 'wa8w'}, board => {
board.systemReset();
board.samplingInterval = 250;
pir = getPir(board, 11);
led = getLed(board, 10);
led.off();
pir.on("detected", () => {
light.className = "on";
led.on();
});
pir.on("ended", () => {
light.className = "off";
led.off();
});
});
</script>
</body>