Intentando reconectar…
let conectado = false
bluetooth.startUartService()
bluetooth.onBluetoothConnected(function () {
conectado = true
basic.showIcon(IconNames.Yes)
})
bluetooth.onBluetoothDisconnected(function () {
conectado = false
basic.showIcon(IconNames.No)
})
basic.showIcon(IconNames.Heart)
basic.forever(function () {
if (conectado) {
let linea = ""
linea = "T:" + input.temperature()
linea = linea + ",L:" + input.lightLevel()
linea = linea + ",S:" + input.soundLevel()
linea = linea + ",X:" + input.acceleration(Dimension.X)
linea = linea + ",Y:" + input.acceleration(Dimension.Y)
linea = linea + ",Z:" + input.acceleration(Dimension.Z)
if (input.buttonIsPressed(Button.A)) {
linea = linea + ",A:1"
} else {
linea = linea + ",A:0"
}
if (input.buttonIsPressed(Button.B)) {
linea = linea + ",B:1"
} else {
linea = linea + ",B:0"
}
if (input.logoIsPressed()) {
linea = linea + ",P:1"
} else {
linea = linea + ",P:0"
}
bluetooth.uartWriteLine(linea)
basic.pause(150)
} else {
basic.pause(200)
}
})