Divide blueToothSerial Response

Please help.

I am righting an app for the Arduino Mega 2560. I want to read parts of the recvData which is char type. How do I do this. I'm new to C.

void blueToothGetData(){
//convert char to string
//char *chr = "this is a char";
//string str = chr;
char recvData =' ';
if(blueToothSerial.available()){//check if there's any data sent from the remote bluetooth shield
recvData = blueToothSerial.read();
}
}

Thanks in advance guys.

Phil

http://arduino.cc/forum/index.php/topic,149014.0.html

Bluetooth works over serial, so keep reading in the chars and store them in a array. You will need a terminating char like a period.

char DATA_Array[20];
int count =0;

In your loop()

if(Serial.available()) {
char DATA = Serial.read();
if(DATA == '.') {
// display data then clear it for new data
// set count back to zero
}
else {
Data_Array[count++] = DATA;
}
}

Thanks Guys for your responses.

However I forgot to mention For Sending and Receiving from the bluetooth I am using SoftwareSerial.H Here In lies my problem. It appears that A char variable as in my example above, appears to read the whole of the buffer.

For example a char in this case readData lwhen used with readData = bluetoothSerial.read() returns the entire buffer.

to test this I used the following code with out a loop, just a single call:

readData = blueToothSerial.read();
Serialprint(readData+"\r\n");

Printed in the Monitor was an entire string.

So how can I strip readData apart.

Thanks for all your efforts in replying I appreciate it.

Phil

It's about time to post your whole program, don't you think ?

For instance, what data type is readData in your latest example and how/where is bluetoothSerial defined ?

For example a char in this case readData lwhen used with readData = bluetoothSerial.read() returns the entire buffer.

Only when there is only one character in the buffer, which is probably most of the time, considering that serial data arrival is orders of magnitude slower than the Arduino can read it.