-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServomotor_Turn.html
42 lines (38 loc) · 1.22 KB
/
Servomotor_Turn.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>Servomotor Turn</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>
span {font-size: 20px;}
</style>
</head>
<body>
<span>數值:</span><span id="bar_value">90</span><br>
<span>拉霸:</span>
<input type="range" min="0" max="180" step="5" value="90" id="bar">
<script>
var servo;
var bar = document.getElementById("bar");
var bar_value = document.getElementById("bar_value");
boardReady({device: 'wa8w'}, board => {
board.systemReset();
board.samplingInterval = 20;
servo = getServo(board, 11);
bar.setAttribute("min",0);
bar.setAttribute("max",180);
bar.setAttribute("step",5);
bar.setAttribute("value",90);
bar.oninput = _value => {
_value = bar.value;
bar_value.innerHTML = _value;
servo.angle = _value;
};
});
</script>
</body>