help with serial monitor

sir,
i am working on a android app based control of four servo motors using bluetooth.i have writen the code in which i have to separate a the integer value from a string which comes in and send to the motors and if i check in serial monitor i get the correct value…but once i connect to the bluetooth the controller reads two times and stops responding to the android app.kindly help me…i have also attached the code for refernece
#include <VarSpeedServo.h>
VarSpeedServo base;
VarSpeedServo shoulder;
VarSpeedServo wrist;
VarSpeedServo Sensorboard;
const int speed_mot = 100; //max val =255
void setup()
{
Serial.begin(9600);
base.attach(3);
shoulder.attach(5);
wrist.attach(6);
Sensorboard.attach(9);
base.write(0, speed_mot, true);
delay(100);
shoulder.write(0, speed_mot, true);
delay(100);
wrist.write(0, speed_mot, true);
delay(100);
Sensorboard.write(0, speed_mot, true);
delay(100);
}
void loop()
{
String a;
char s1[4];
char s2[4];
char s3[4];
char s4[4];
char s5[4];
int n, i, j, k, l, o, p, m, se1, se2, se3, se4, se5;
int count = 0;
if (Serial.available() > 0)
{
a = Serial.readString();
for (i = 0, j = 0, k = 0, m = 0, l = 0, p = 0; a*; i++)*

  • {*
    _ if ((a != ‘#’) && (count == 0))_
    * {*
    _ s1[j++] = a*;
    }
    if ((a == ‘+’) && (count == 0))
    {
    s1[j - 1] = ‘\0’;
    count = 1;
    printf("s1 end,a=%c\n", a);
    printf(“count after s1=%d\n”, count);
    }
    else if ((a != ‘+’) && (count == 1))
    {
    printf(“test\n”);
    s2[k++] = a;
    }
    else if ((a == ‘+’) && (count == 1))
    {
    s2[k] = ‘\0’;
    count = 2;
    printf("s2 end,a=%c\n", a);
    printf(“count after s1=%d\n”, count);
    }
    else if ((a != ‘+’) && (count == 2))
    {
    s3[l++] = a;
    }
    else if ((a == ‘+’) && (count == 2))
    {
    s3[l] = ‘\0’;
    count = 3;
    }
    else if ((a != ‘~’) && (count == 3))
    {
    s4[m++] = a;
    }
    else if ((a == ‘~’) )
    {
    s4[m] = ‘\0’;
    }
    }
    se1 = (atoi(s1));
    se2 = (atoi(s2));
    se3 = (atoi(s3));
    se4 = (atoi(s4));
    Serial.println(se1);
    Serial.println(se2);
    Serial.println(se3);
    Serial.println(se4);
    Serial.println("******");_
    base.write(se1, speed_mot, true);

    shoulder.write(se2, speed_mot, true);

    wrist.write(se3, speed_mot, true);

    Sensorboard.write(se4, speed_mot, true);

    _ }

    }

    robotarm.ino (2.07 KB)_

Please use code tags (modify your post)

type ``` [code] ```

paste your code after that type ``` [code] ``` after that

The result will look like

your pasted code

You've been a member here for almost 3 years, a lot longer than me, so you should be well aware of the rules regarding code tags.

But OP hasn't posted for two years and hence has forgotten all the rules ;) And he/she has a post count that is about 0.1% of yours :D

sterretje: And he/she has a post count that is about 0.1% of yours :D

Don't remind me. I spend far too much time sitting here. :D (I don't work any more, and have to do something to keep my brain active.)