so i have connected a HM-10 bluetooth module and a servo motor to my arduino mega and im using an app on my phone to try and control the position of the servo motor using a slider. The problem is when is use the slider the servo just goes all over the place and jitters. i tried some troubleshooting by printing the values read by the HM-10 and it blurts out some random numbers and then the actual position the slider is on. i need help and would like to control the servo smoothly with my phones slider without any jittering. also the app im using is IOS bluetooth for arduino
#include <SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial mySerial(10, 11);
Servo myServo;
int servoPin=9;
int servoPos;
void setup() {
mySerial.begin(9600);
Serial.begin(9600);
myServo.attach(servoPin);
}
void loop() {
while(mySerial.available()==0){
}
servoPos=mySerial.parseInt();
myServo.write(servoPos);
Serial.println(servoPos);
}