This app communicates between Android and a micro:bit device. You can transmit numeric data as text or value. The UART communication also has to be implemented at the micro:bit device.
Text enabled: text data transmission
Text disabled: numeric data transmission
Newline enabled: '\n' (newline) added
Newline disabled: no additional data
Zero enabled (Touch/Sense enabled): Send 0 on release button
For PXT programming you have to enable Text and Newline.
Requirements:
- Min. Android 4.4
- Bluetooth Low Energy (BLE)
- Paired devices !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- micro:bit programm (developed by yourself)
PXT javascript example:
let str = ""
let connected = 0
input.onButtonPressed(Button.A, () => {
if (connected) {
bluetooth.uartWriteString("A")
}
})
bluetooth.onBluetoothConnected(() => {
connected = 1
})
bluetooth.onBluetoothDisconnected(() => {
connected = 0
})
bluetooth.startUartService()
basic.forever(() => {
if (connected == 1) {
str = bluetooth.uartReadUntil(serial.delimiters(Delimiters.NewLine))
if (str == "B") {
basic.showString("Hi")
} else {
basic.showString(str)
}
} else {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # . # .
`)
}
})
Remark: Do not forget to pair devices (after micro:bit program changes)