Arduino - Android Communication SeekBar Value
<p>I have an app which communicate Arduino via Bluetooth. I want to change speeds of DC motors using seekbar, there is not any problem about communication, the problem is format I think, because while I am moving the bar, I check the results from Arduino Serial Port screen, and see different symbols like ! " # ' $ ) ( * &lt; : and some of them are normal character like A,B,C... I need only integer between 0-255 Found and tried <a href="https://stackoverflow.com/questions/14893860/android-arduino-bluetooth-communication">these answer</a> but it did not help</p>

<p>This is Android part</p>

<pre><code>seekbar = (SeekBar)findViewById(R.id.seekBar);
seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        int speed= 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            speed = progress;

            if(btSocket!=null){
                try {
                    btSocket.getOutputStream().write(speed);
                } catch (IOException e){
                    msg("Error");
                }
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });
</code></pre>

<p>This is Arduino Part</p>

<pre><code>int pwm_a = 3;  
int pwm_b = 11; 
int dir_a = 12; 
int dir_b = 13;  
char incomingByte; //incoming data for directions  
int speed; // incoming data for speed

void setup()
{
  Serial.begin(9600);
  pinMode(pwm_a, OUTPUT);
  pinMode(pwm_b, OUTPUT);
  pinMode(dir_a, OUTPUT);
  pinMode(dir_b, OUTPUT);

  analogWrite(pwm_a, 0);  
  analogWrite(pwm_b, 0);

}

void loop()
{
  if(Serial.available() &gt; 0){ //if the data came
incomingByte = Serial.read();
speed = Serial.read();


if (incomingByte == 'F'){
forward();}
  else if (incomingByte == 'B'){
back();}
if (incomingByte == 'R'){
right();}
if (incomingByte == 'L'){
left();}
if (incomingByte == 'S'){
stop();
    }
  }
}

void forward() 
{ digitalWrite(dir_a, HIGH);
  digitalWrite(dir_b, HIGH);  
  analogWrite(pwm_a, speed);    
  analogWrite(pwm_b, speed);
}

void back() 
{ digitalWrite(dir_a, LOW); 
  digitalWrite(dir_b, LOW);  
  analogWrite(pwm_a, speed);    
  analogWrite(pwm_b, speed);
}
void right() 
{ digitalWrite(dir_a, LOW); 
  digitalWrite(dir_b, HIGH);  
  analogWrite(pwm_a, speed);    
  analogWrite(pwm_b, speed);
}

void left() 
{ digitalWrite(dir_a, HIGH); 
  digitalWrite(dir_b, LOW);  
  analogWrite(pwm_a, speed);    
  analogWrite(pwm_b, speed);
}
void stop() 
{ digitalWrite(dir_a, LOW); 
  digitalWrite(dir_b, LOW);  
  analogWrite(pwm_a, 0);    
  analogWrite(pwm_b, 0);
}
</code></pre>