Bluetooth Protocol


  1. DIONYZUZ

    DIONYZUZ Member

    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.

    Advertisement
  2. DIONYZUZ

    DIONYZUZ Member

    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.
  3. DIONYZUZ

    DIONYZUZ Member

    I finally got it working.. I don't think I'll be using this forum anymore :/

Share This Page