Pages: [1]   Go Down
Author Topic: JY-MCU v1.05 Bluetooth Module with Arduino Mega 1280  (Read 989 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I'm having trouble getting this Bluetooth module to work. Using Android's Amarino app, a connection with the module can be established, but the module doesn't receive any data sent to it from the app. The code I have been working with is as follows:

Code:
#include <MeetAndroid.h>


#include <SoftwareSerial.h>
#define SOP '<'
#define EOP '>'

bool started = false;
bool ended = false;

char inData[80];
byte index;

String readString;

int runOnce = 1;

SoftwareSerial mySerial(19, 18); // RX, TX

void setup() 
{

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  Serial.println("Correct baud rate selected [9600]. Connection established");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
}

void loop() // run over and over
{

  //expect a string like wer,qwe rty,123 456,hyre kjhg,
  //or like hello world,who are you?,bye!,
  while (Serial.available()) {
    delay(10);  //small delay to allow input buffer to fill

    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      break;
    }  //breaks out of capture loop to print readstring
    readString += c;
  } //makes the string readString 

  if (readString.length() >0) {
    Serial.println(readString); //prints string to serial port out

    readString=""; //clears variable for new input
  }

}


Many thanks

Logged

Pages: [1]   Go Up
Jump to: