how to interpret data from Serial.read()

Pls help with this...

While working on a code, i needed to use the values send to my HC-05 bluetooth module using a mobile app. Using the Serial.read() function, and printing the values onto the serial monitor, i got a set of values viz. 12,34,54,32. But for the current purpose i need only the first value (ie. 12 (in this eg.)) What shall i do to put the 1st value from those four values obtained on each trigger of a button on the mobile app onto a variable, say "a".

pls rspond... :confused:

What shall i do to put the 1st value from those four values obtained on each trigger of a button on the mobile app onto a variable, say "a".

The first value is '1'. There are 11 values listed ('1', '2', ',', '3', '4', ',', etc.).

If you'd care to rephrase your question, then we can help.

Sir, I've been sending data from a mobile bluetooth controller app onto my HC-05 connected to my Arduino. In the controller(app) there are four sliders to output different values to the arduino. Suppose i put the slider in one position, the app outputs a data like, say 12,33,55,22. where 12 corresponds to the 1st slider's present state and 33, 55 and 22 for 2,3 and 4th sliders respectively...Now suppose for an operation i need only the state of the first slider...ie. i need the value 12...how can i do that?

how can i do that?

int val = 0;
while(Serial.available() > 0)
{
   char letter = Serial.read();
   if(letter != ',')
   {
      val *= 10;
      val += letter - '0';
   }
   else
      break;
}

// Add some code to wait for and throw away the rest of the packet

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example.

...R