Link successfully established and able to send data.
Android is sending SeekBar data when ever we change it.
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if(seekBar.getId() == R.id.seekBar)
{
speed.setText(String.valueOf(progress));
String outputData = String.valueOf(progress);
streams.write(outputData.getBytes());
}
}
streams.write() writes data to the OutputStream of the Socket.
Problem is with the format of data.If I Send ’25’ arduino is receiving ‘2’,’5′ when I do Serial.read().
What is the format of data, when outputData is converted into bytes? Is everything terminated by \0?
I need to retrieve the whole number instead of single digits.
the arduinoboard seems to read the RX-Stream byte by byte. If you send “25” it transmits the ascii byte for the character’2′ (which is 0x32 / decimal 50) and then the ascii representation for the character ‘5’ (which is 0x35 / decimal 53).
The arduino interprets these numbers as characters. So if the number you want to transmit is lower than 256 you can do:
On Android:
To make sure the Arduino interprets it right, use the received character as a short and not as a character.
Hope this helps