Merge pull request #142 from bluetooth-mdw/master
Documentation for Bluetooth LED service block
33
docs/reference/bluetooth/on-bluetooth-connected.md
Executable file
@ -0,0 +1,33 @@
|
||||
# On Bluetooth Connected
|
||||
|
||||
![](/static/bluetooth/Bluetooth_SIG.png)
|
||||
|
||||
For another device like a smartphone to use any of the Bluetooth "services" which the micro:bit has, it must first connect to the micro:bit. This block starts an [event handler](/reference/event-handler) which in this case will run when something connects to your micro:bit using Bluetooth.
|
||||
|
||||
You could use this event handler to display a letter "C" on the micro:bit LED grid so you know you have a Bluetooth connection. Or you might want to send some data you've been accumulating to your smartphone as soon as it connects to your micro:bit. Maybe you've been using the accelerometer in your micro:bit to count your steps for example. Using this event handler you could send the accumulated step count to your phone when it establishes a Bluetooth connection.
|
||||
|
||||
~~~~sig
|
||||
bluetooth.onBluetoothConnected(() => {
|
||||
});
|
||||
~~~~
|
||||
|
||||
### Example: Displaying "C" when another device connects to the micro:bit over Bluetooth
|
||||
|
||||
~~~~blocks
|
||||
bluetooth.onBluetoothConnected(() => {
|
||||
basic.showString("C");
|
||||
});
|
||||
~~~~
|
||||
|
||||
### Video - on Bluetooth connected
|
||||
|
||||
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_on_connected.png)](
|
||||
http://www.youtube.com/watch?v=HyBcsD9Eh6I "Click to launch YouTube video"
|
||||
)
|
||||
|
||||
### See also
|
||||
|
||||
[Bluetooth SIG](https://www.bluetooth.com)
|
||||
|
||||
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
|
||||
|
33
docs/reference/bluetooth/on-bluetooth-disconnected.md
Executable file
@ -0,0 +1,33 @@
|
||||
# On Bluetooth Disconnected
|
||||
|
||||
![](/static/bluetooth/Bluetooth_SIG.png)
|
||||
|
||||
For another device like a smartphone to use any of the Bluetooth "services" which the micro:bit has, it must first connect to the micro:bit. This block starts an [event handler](/reference/event-handler) which in this case will run when a device which is connected to your micro:bit over Bluetooth disconnects.
|
||||
|
||||
You could use this event handler to display a letter "D" on the micro:bit LED grid so you know that the Bluetooth connection has been closed.
|
||||
|
||||
~~~~sig
|
||||
bluetooth.onBluetoothDisconnected(() => {
|
||||
});
|
||||
~~~~
|
||||
|
||||
### Example: Displaying "D" when a Bluetooth connection to the micro:bit is closed
|
||||
|
||||
~~~~blocks
|
||||
bluetooth.onBluetoothDisconnected(() => {
|
||||
basic.showString("D");
|
||||
});
|
||||
~~~~
|
||||
|
||||
### Video - on Bluetooth disconnected
|
||||
|
||||
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_on_disconnected.png)](
|
||||
http://www.youtube.com/watch?v=HyBcsD9Eh6I "Click to launch YouTube video"
|
||||
)
|
||||
|
||||
### See also
|
||||
|
||||
[Bluetooth SIG](https://www.bluetooth.com)
|
||||
|
||||
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
|
||||
|
38
docs/reference/bluetooth/start-accelerometer-service.md
Executable file
@ -0,0 +1,38 @@
|
||||
# Bluetooth Accelerometer Service
|
||||
|
||||
![](/static/bluetooth/Bluetooth_SIG.png)
|
||||
|
||||
The Bluetooth accelerometer service allows another device such as a smartphone to wirelessly receive data from the micro:bit's accelerometer. An accelerometer detects motion. More precisely, it measures acceleration in one or more of three directions which we call X, Y and Z.
|
||||
|
||||
Using the Bluetooth accelerometer service you could, for example, create a smartphone application which makes a loud noise whenever your micro:bit (or the important thing you've attached it to) is moved. Or you could use your micro:bit to control the movement of a cartoon character in a game on your smartphone just by tilting the micro:bit in the direction you want the character to move in.
|
||||
|
||||
No additional code is needed on the micro:bit to use the Bluetooth accelerometer service from another device.
|
||||
|
||||
~~~~sig
|
||||
bluetooth.startAccelerometerService();
|
||||
~~~~
|
||||
|
||||
### Example: Starting the Bluetooth accelerometer service
|
||||
|
||||
The following code shows the Bluetooth accelerometer service being started:
|
||||
|
||||
~~~~blocks
|
||||
bluetooth.startAccelerometerService();
|
||||
~~~~
|
||||
|
||||
### Video - Accelerometer service demo - Starts at 0:18
|
||||
|
||||
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_accelerometer.png)](
|
||||
http://www.youtube.com/watch?v=aep_GVowKfs "Click to launch YouTube video"
|
||||
)
|
||||
|
||||
### Advanced
|
||||
|
||||
For more advanced information on the micro:bit Bluetooth accelerometer service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/accelerometer-service/)
|
||||
|
||||
### See also
|
||||
|
||||
[Bluetooth SIG](https://www.bluetooth.com)
|
||||
|
||||
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
|
||||
|
42
docs/reference/bluetooth/start-button-service.md
Executable file
@ -0,0 +1,42 @@
|
||||
# Bluetooth Button Service
|
||||
|
||||
![](/static/bluetooth/Bluetooth_SIG.png)
|
||||
|
||||
The Bluetooth button service makes it possible for another device such as a smartphone to be notified wirelessly whenever a button on the front of a micro:bit is pressed. Each of the two micro:bit buttons can be in one of three possible states:
|
||||
|
||||
* Not pressed
|
||||
* Pressed
|
||||
* Long press - pressed and held down for at least 2 seconds
|
||||
|
||||
The button service allows you to make other things which are connected to your micro:bit using Bluetooth respond in some way when you press either of the buttons. You could, for example, hide your smartphone somewhere in the room and have it make an amusing noise when you press either of the buttons on your micro:bit. We'll leave it to you to decide what would be amusing.
|
||||
|
||||
No additional code is needed on the micro:bit to use the Bluetooth button service from another device.
|
||||
|
||||
~~~~sig
|
||||
bluetooth.startButtonService();
|
||||
~~~~
|
||||
|
||||
### Example: Starting the Bluetooth button service
|
||||
|
||||
The following code shows the Bluetooth button service being started:
|
||||
|
||||
~~~~blocks
|
||||
bluetooth.startButtonService();
|
||||
~~~~
|
||||
|
||||
### Video - Button service demo - Starts at 0:59
|
||||
|
||||
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_button.png)](
|
||||
http://www.youtube.com/watch?v=aep_GVowKfs "Click to launch YouTube video"
|
||||
)
|
||||
|
||||
### Advanced
|
||||
|
||||
For more advanced information on the micro:bit Bluetooth button service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/button-service/)
|
||||
|
||||
### See also
|
||||
|
||||
[Bluetooth SIG](https://www.bluetooth.com)
|
||||
|
||||
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
|
||||
|
38
docs/reference/bluetooth/start-led-service.md
Executable file
@ -0,0 +1,38 @@
|
||||
# Bluetooth LED Service
|
||||
|
||||
![](/static/bluetooth/Bluetooth_SIG.png)
|
||||
|
||||
The Bluetooth LED service allows another device such as a smartphone to send short text strings or patterns over a Bluetooth connection to a micro:bit for display on its LED matrix. Text will scroll across the micro:bit and the speed at which it scrolls can also be controlled using the Bluetooth LED service. Devices using the LED service may also read the current state of the micro:bit's LED matrix.
|
||||
|
||||
So you could, for example, draw a smiley face in a smartphone app and at the press of a button, have it magically appear on your micro:bit on the other side of the room. Or you could program your smartphone to send a message to your micro:bit whenever your phone receives an email, SMS or social media message so you could wear your micro:bit like a smart watch and leave your phone in your bag.
|
||||
|
||||
No additional code is needed on the micro:bit to use the Bluetooth LED service from another device.
|
||||
|
||||
~~~~sig
|
||||
bluetooth.startLEDService();
|
||||
~~~~
|
||||
|
||||
### Example: Starting the Bluetooth LED service
|
||||
|
||||
The following code shows the Bluetooth LED service being started:
|
||||
|
||||
~~~~blocks
|
||||
bluetooth.startLEDService();
|
||||
~~~~
|
||||
|
||||
### Video - LED service demo starts at 2:00
|
||||
|
||||
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_led.png)](
|
||||
http://www.youtube.com/watch?v=aep_GVowKfs "Click to launch YouTube video"
|
||||
)
|
||||
|
||||
### Advanced
|
||||
|
||||
For more advanced information on the micro:bit Bluetooth LED service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/led-service/)
|
||||
|
||||
### See also
|
||||
|
||||
[Bluetooth SIG](https://www.bluetooth.com)
|
||||
|
||||
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
|
||||
|
38
docs/reference/bluetooth/start-magnetometer-service.md
Executable file
@ -0,0 +1,38 @@
|
||||
# Bluetooth Magnetometer Service
|
||||
|
||||
![](/static/bluetooth/Bluetooth_SIG.png)
|
||||
|
||||
The Bluetooth magnetometer service allows another device such as a smartphone to wirelessly receive data from the micro:bit's magnetometer. The magnetometer measures the strength and direction of magnetic fields including the earth's and so it can be used as a digital compass and indicate the way the micro:bit is pointing relative to magnetic north.
|
||||
|
||||
Using the Bluetooth magnetometer service you could, for example, create a smartphone application which displays your direction of travel, updating it in real time.
|
||||
|
||||
No additional code is needed on the micro:bit to use the Bluetooth magnetometer service from another device.
|
||||
|
||||
~~~~sig
|
||||
bluetooth.startMagnetometerService();
|
||||
~~~~
|
||||
|
||||
### Example: Starting the Bluetooth magnetometer service
|
||||
|
||||
The following code shows the Bluetooth magnetometer service being started:
|
||||
|
||||
~~~~blocks
|
||||
bluetooth.startMagnetometerService();
|
||||
~~~~
|
||||
|
||||
### Video - Magnetometer service demo
|
||||
|
||||
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_magnetometer.png)](
|
||||
http://www.youtube.com/watch?v=C_0VL4Gp4_U "Click to launch YouTube video"
|
||||
)
|
||||
|
||||
### Advanced
|
||||
|
||||
For more advanced information on the micro:bit Bluetooth magnetometer service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/magnetometer-service/)
|
||||
|
||||
### See also
|
||||
|
||||
[Bluetooth SIG](https://www.bluetooth.com)
|
||||
|
||||
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
|
||||
|
38
docs/reference/bluetooth/start-temperature-service.md
Executable file
@ -0,0 +1,38 @@
|
||||
# Bluetooth Temperature Service
|
||||
|
||||
![](/static/bluetooth/Bluetooth_SIG.png)
|
||||
|
||||
A micro:bit is able to provide a rough measure of the current environmental temperature. It's an approximation only as in fact the temperature value is inferred from the temperature of its main processor. The Bluetooth temperature service allows another device such as a smartphone to wirelessly find out the micro:bit's current temperature reading or to receive a constant stream of temperature data values. Temperature values are expressed in degrees celsius.
|
||||
|
||||
Using the Bluetooth temperature service you could turn your smartphone or tablet into a graphical thermometer using your micro:bit as the sensor.
|
||||
|
||||
No additional code is needed on the micro:bit to use the Bluetooth temperature service from another device.
|
||||
|
||||
~~~~sig
|
||||
bluetooth.startTemperatureService();
|
||||
~~~~
|
||||
|
||||
### Example: Starting the Bluetooth temperature service
|
||||
|
||||
The following code shows the Bluetooth temperature service being started:
|
||||
|
||||
~~~~blocks
|
||||
bluetooth.startTemperatureService();
|
||||
~~~~
|
||||
|
||||
### Video - Temperature service demo - Starts at 3:05
|
||||
|
||||
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_temperature.png)](
|
||||
http://www.youtube.com/watch?v=aep_GVowKfs "Click to launch YouTube video"
|
||||
)
|
||||
|
||||
### Advanced
|
||||
|
||||
For more advanced information on the micro:bit Bluetooth temperature service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/temperature-service/)
|
||||
|
||||
### See also
|
||||
|
||||
[Bluetooth SIG](https://www.bluetooth.com)
|
||||
|
||||
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
|
||||
|
BIN
docs/static/bluetooth/microbit_accelerometer.png
vendored
Executable file
After Width: | Height: | Size: 202 KiB |
BIN
docs/static/bluetooth/microbit_button.png
vendored
Executable file
After Width: | Height: | Size: 211 KiB |
BIN
docs/static/bluetooth/microbit_led.png
vendored
Executable file
After Width: | Height: | Size: 168 KiB |
BIN
docs/static/bluetooth/microbit_magnetometer.png
vendored
Executable file
After Width: | Height: | Size: 188 KiB |
BIN
docs/static/bluetooth/microbit_on_connected.png
vendored
Executable file
After Width: | Height: | Size: 254 KiB |
BIN
docs/static/bluetooth/microbit_on_disconnected.png
vendored
Executable file
After Width: | Height: | Size: 272 KiB |
BIN
docs/static/bluetooth/microbit_temperature.png
vendored
Executable file
After Width: | Height: | Size: 207 KiB |