Hi,
I am having a little bit of trouble with using the bt.send command in Scott Harrison’s plugin.
Currently I am using the example app and I’ve simply added another two buttons to send two different characters. I want to send the two separate characters ‘a’ & ‘b’ to my Arduino device to turn an LED on then off via Bluetooth. The micro controller is programmed to turn on the LED when it receives the character ‘a’ in its serial terminal and then turn off the LED when it receives ‘b’. This functionality is able to work with any of the other serial command/Bluetooth terminal app available on the play store.
The example app is able to connect to my Bluetooth device using my Android phone without any issues but I can only send one character from one of the buttons then I have to reopen the app to send the other character with the other button and I’m not sure of how to overcome this.
I should mention that I am a beginner with this.
Below is the code that I added to the example app:
local bluetoothSend = widget.newButton{
label = “Send a”,
x = display.contentCenterX,
y = display.actualContentHeight-85,
onRelease = function ( event )
bt.send(“a”)
end,
}
local bluetoothSendb = widget.newButton{
label = “Send b”,
x = display.contentCenterX,
y = display.actualContentHeight-30,
onRelease = function ( event )
bt.send(“b”)
end,
}
I haven’t really changed much in the example app other than a few minor position changes and size adjustments.
Your assistance will be much appreciated!
Many thanks,
rsp355