-
Notifications
You must be signed in to change notification settings - Fork 4
/
microbit-web-bluetooth-accelerometer.html
45 lines (45 loc) · 1.99 KB
/
microbit-web-bluetooth-accelerometer.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
43
44
45
<!DOCTYPE html>
<html>
<head>
<title>Web Bluetooth micro:bit Accelerometer</title>
<h1>Web Bluetooth micro:bit Accelerometer</h1>
<p>Scan Bluetooth devices (using "BBC micro:bit" as namePrefix filter). Allows to interact with the micro:bit using the Bluetooth Accelerometer service.<br>Example MakeCode micro:bit project <a href="https://makecode.microbit.org/_i2cRUvcd34Ai" target="_blank">here</a> (or <a href="https://makecode.microbit.org/#pub:_i2cRUvcd34Ai" target="_blank">here</a> to open in MakeCode directly).</p>
</head>
<body id="body" style="background-color:#FFD0D0">
<button onclick="connect()">Connect</button>
<button onclick="disconnect()">Disconnect</button>
<h2>Accelerometer Data (mg)</h2>
<table>
<tr>
<td>x:</td>
<td id="accelerometerX">-</td>
</tr>
<tr>
<td>y:</td>
<td id="accelerometerY">-</td>
</tr>
<tr>
<td>z:</td>
<td id="accelerometerZ">-</td>
</tr>
</table>
<h2>Accelerometer Period (ms)</h2>
<input type="text" id="accelerometerPeriodText" disabled="true">
<button onclick="readAccelerometerPeriod()">Read</button>
<br>
<select id="accelerometerPeriodSelect">
<option value="1">1</option>
<option value="2">2</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="80">80</option>
<option value="160">160</option>
<option value="640">640</option>
</select>
<button onclick="writeAccelerometerPeriod()">Write</button>
<h2>Log <button onclick="clearLog()">Clear</button></h2>
<p id="log" style="font-family:'Courier New',Courier,monospace"></p>
</body>
<script src="microbit-web-bluetooth-accelerometer.js"></script>
</html>