1. Are you ready for the Galaxy S20? Here is everything we know so far!

Bluetooth Protocol

Discussion in 'Android Development' started by DIONYZUZ, Dec 30, 2012.

  1. DIONYZUZ

    DIONYZUZ Lurker
    Thread Starter

    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.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. DIONYZUZ

    DIONYZUZ Lurker
    Thread Starter

    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 Lurker
    Thread Starter

    I finally got it working.. I don't think I'll be using this forum anymore :/
     
Loading...
Similar Threads - Bluetooth Protocol
  1. centricloon
    Replies:
    8
    Views:
    201
  2. Amarkit
    Replies:
    0
    Views:
    389
  3. melani78
    Replies:
    3
    Views:
    819
  4. FairyTalePink
    Replies:
    2
    Views:
    782
  5. Gilmour
    Replies:
    2
    Views:
    485
  6. Viridel
    Replies:
    8
    Views:
    712
  7. HerrimanCoder
    Replies:
    3
    Views:
    1,096
  8. Sillycat41
    Replies:
    13
    Views:
    1,505
  9. ArtemisTwo
    Replies:
    7
    Views:
    479
  10. Jodi Holland
    Replies:
    2
    Views:
    879

Share This Page

Loading...