Robot Arm Servo-position from iPad


i'm trying send servo position of robot arm simulator ipad.
i'm using , arduino leonardo  , redbearlab blemini dongle.
the thing is, want keep sending servos values every .01 seconds -or when servo value changes (almost every .01 seconds)-. have 4 servos, , i'm trying find best way move them.
i've tried 1 servo every .01 seconds, arduino got stucked. tried on refreshing every .05 seconds , servo did move expected. think there might problem servo.write routine delays micro , servo didn't move. think problem may baudrate or makes serial module have problem. guys have ideas?

the code looks
#include <ble_mini.h>
#include <servo.h>


servo myservo;
servo myservo2;
servo myservo3;
servo myservo4;
void setup()
{
  blemini_begin(57600);
  myservo.attach(9);
myservo2.attach(10);
myservo3.attach(11);
myservo4.attach(13);
}

void loop()
{
 
  // if data ready
  while ( blemini_available() == 2 )
  {
    //read out command , data
    byte data0 = blemini_read(); //the servo going move
    byte data1 = blemini_read();
   
    if (data0 == 0x01) 
    {
      myservo.write(data1);
    }

   if (data0 == 0x02) 
    {
      myservo2.write(data1);
    }

  else  if (data0 == 0x03) 
    {
      myservo3.write(data1);
    }
   
else if (data0 == 0x04) 
    {
      myservo4.write(data1);
    }

    else if (data0 == 0x05) // command reset
    {
      myservo.write(90);
     myservo2.write(90);
     myservo3.write(90);
     myservo4.write(90);
    }
  }
 
 
}

quote
i think problem may baudrate

you have 1 baud rate. if arduino , ipad communicate @ all, problem not baud rate. on it.

one thing may need deal synchronization. serial data not guaranteed delivered correctly. if byte gets mangled, out of sync. you'll reading position the servo number , servo number position.

in reset mode, still sending 2 values?

code: [select]
servo myservo;
servo myservo2;
servo myservo3;
servo myservo4;

nothing, 2, 3, 4... count that? sure not joe's servos? really, now, can't come names reflect servo doing?


Arduino Forum > Topics > Robotics (Moderator: fabioc84) > Robot Arm Servo-position from iPad


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support