-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClick_Switch_Yellow-Red_LED.html
42 lines (39 loc) · 1.29 KB
/
Click_Switch_Yellow-Red_LED.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>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Click Switch Yellow & Red 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 led_red, led_yellow;
var light = document.getElementById("light");
boardReady({device: 'wa8w'}, board => {
board.systemReset();
board.samplingInterval = 250;
led_red = getLed(board, 10);
led_yellow = getLed(board, 11);
led_red.off();
led_yellow.on();
light.className = "off";
light.addEventListener("click", () => {
led_red.toggle();
led_yellow.toggle();
light.className = light.className == "on" ? "off" : "on";
});
});
</script>
</body>