sensitivity of servo that is controlled via android phone

Good day everyone! just like to ask for an assistance on how to make the motion of the servo motor more sensitive with the tilt of the android phone... our program was to control the tilt of the ball maze board via android phone... our code was also given... we are just wondering if this is just the limitation of the Bluetooth connection... we are using amarino application also for the connection between android phone and bluesmirf... here's the code... #include #include float data[3] = {0}; int intdata[3] = {0}; int i = 1; Servo myservo; Servo myservo2; int pos = 0; // MeetAndroid meetAndroid(); // you can define your own error function to catch messages // where not fuction has been attached for MeetAndroid meetAndroid(error); float previousdata = 0; int elapsedtime = 0; void error(uint8_t flag, uint8_t values) {   Serial.print("ERROR: ");   Serial.print(flag); } void setup() {   Serial.begin(115200); //begin serial link @ 9600bps   // register callback functions, which will be called when an associated event occurs.   // - the first parameter is the name of your function (see below)   // - match the second parameter ('A', 'B', 'a', etc...) with the flag on your Android application   meetAndroid.registerFunction(floatValues, 'A');    myservo.attach(9); //Attach the servo to pin eleven   myservo2.attach(10); } void StopCar() {   myservo.write(90);   myservo2.write(90); } void loop() {   myservo.write(90);   myservo2.write(90);   meetAndroid.receive(); // you need to keep this in your loop() to receive events } void floatValues(byte flag, byte numOfValues) {   // create an array where all event values should be stored   // the number of values attached to this event is given by   // a parameter(numOfValues)     // call the library function to fill the array with values (floats)   meetAndroid.getFloatValues(data);     for (int i=0; i<3;i++)   {     meetAndroid.send(data[i]);//Used for debug purposes   }   if (-10<=data[1]<=10)   {      intdata[1] = int(data[1]); //Cast the X axis float value to int      intdata[1] = intdata[1]+10;      pos = intdata[1]*9;      myservo.write(pos);   }   if (-10<=data[0]<=10)   {     intdata[0] = int(data[0]);     intdata[0] = intdata[0]+10;     pos = intdata[0]*9;     myservo.write(pos);   }   if (previousdata == data[0]) { //If the data's still the same (It should have been changed by the meetAndroid.getFloatValues(data) function)      if ((elapsedtime-millis())>=1000) { //If the car has lost the signal more than 1sec, then stop the car         StopCar();      }    }             }

Posted by maevalen 6 years ago