• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Bluetooth Protocol

DIONYZUZ

Lurker
Oct 3, 2012
8
0
Hello, I am developing an app that will use bluetooth and return values to an app. I am having some problems using my Arduino (Uno rev3) Development board to send data to the board from my arduino program. I am using a sample code to test with turning on and off an LED. So far I have tested the Arduino code with its serial monitor to send data and it seems that it accepts sending the "D" letter value. I believe it is accepting its command because it is used to its own protocol of bytes or something similar. I am not sure if I am using the correct command to send data from my android to the arduino here is a snippet of the command to send a capital "D" to turn on a LED:

public class LEDtest extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.ledtest);
final Button tbutton = (Button) findViewById(R.id.tbutton);

tbutton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
ConnectedThread.write("D".getBytes());

}
});

}



}
I want to know if there's a command that will change it to to a universal protocol of bytes or if there's something I'm missing.
 
I thought it would work by switching the write function part to:
String S = "D";
ConnectedThread.write(S.getBytes());


But it still didnt work I am aware there are different ways of sending the data via serial such as getString, getAsciiBytes, getAsciiString etc, but they do not work in the same format as this way. I am very lost and do not know how my Arduino will expect recieving the "D" to turn on an LED.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones