5 Replies Latest reply on Apr 6, 2016 3:27 PM by Sullivan

    Hc-06 Bluetooth to intel galileo problem. Cannot figure out the code

    Sullivan

      Hi Everyone,
      I'm currently trying to figure out how to connect my android phone to my Intel Galileo via the Hc-06(for the past month). My plan is to connect them up to use an app (bluetooth serial app) to drive a rc car. I just cannot get my phone to send the data to the hc-06. I have a very simple start off code which is included below which turns on and off an led and then I hope to go from there, but I cant figure out how to change the code further to use with the hc-06. I have downloaded the Software serial files and connected up everything like I was supposed to. just stuck on the code. Ii will be forever grateful as this is a part off my final year project Thanks!

       

       

      It's a simple sketch which waits for a character on serial

      and in case of a desirable character, it turns an LED on/off.

       

       

      Possible string values:

      a (to turn the LED on)

      b (tor turn the LED off)

      */

       

       

      char junk;

      String inputString="";

       

      void setup()                    // run once, when the sketch starts

      {

      Serial.begin(9600);            // set the baud rate to 9600, same should be of your Serial Monitor

      pinMode(13, OUTPUT);

      }

       

       

      void loop()

      {

        if(Serial.available()){

        while(Serial.available())

          {

            char inChar = (char)Serial.read(); //read the input

            inputString += inChar;        //make a string of the characters coming on serial

          }

          Serial.println(inputString);

          while (Serial.available() > 0) 

          { junk = Serial.read() ; }      // clear the serial buffer

          if(inputString == "a"){         //in case of 'a' turn the LED on

            digitalWrite(13, HIGH); 

          }else if(inputString == "b"){   //incase of 'b' turn the LED off

            digitalWrite(13, LOW);

          }

          inputString = "";

        }

      }