Hello,
I`m receiving data from arduino via bluetooth module that gets writen to int with this command:
if(Blue.available()>0)
{
data = Blue.parseInt();
}
Android is sending values from 100 to 350 (slider aka seekbar values) to bluetooth and my problem is that it sends them too quickly. So instead of 150 for example I get 150151152...
Obvious fix would be to set java code for arduino app to send values slower. I tryed to slow the process down, but no luck. Java realy makes me strugle. Error after error, nothing seems good for it.
So I would rather solve this in android.
So is there a way when int data is 150151152 for example that I can make it to seperate this values to 150 151 152 and get them to another int?
How about looking through the several methods of Serial in the reference?
do you have control about the characters that are sended by your java-code?
if yes you could add a beginning and ending-character
like "<150> and then receive a string drop bytes that are unequal to "<" until you find a beginning-sogn
read in the characters until eding-sign ">"
Insert commas between the individual numbers and send with start and end markers, like StefanL38 says, then use the methods in the example #5 of the serial input basics tutorial to read and parse the data.
Thank you both for pointing me the right direction.
I went thru those sites and found a code that I will implement into my code (Example 3 - Receive with start- and end-markers).
I will do this tomorrow and post results.
I did it and it works nice. Thank you.
But I have another problem now. Now arduino doesnt receive other values that dont have <>markers. Is there a way to change the code that it will receive other numbers that doesn`t have those markers?
EDIT: Nevermind, I will try to add markers to all of my commands. I remembered that I had to set thread.sleep in java because I got similar problems before.
Will try to solve that tomorrow and will update the result.
I had just done the code.
It works nicely.
I added <> and
long int data = atoi(receivedChars);
In void loop (int data is my trigger for commands).
And it works perfectly.
Thank you both again.