Could someone tell me why a cant get this to work.

arduino_code.ino (2.86 KB)

BluetoothConfig.ino (3.54 KB)

Could someone tell me why a cant get this to work.

What do they do ?
What should they do ?

  1. start by reading this

  2. post your code in the [ code ] tags

  3. give your topic a more informative heading.

It is supposed to control A robot arm. I cant get to compile so I can upload it.

Post the code in code tags, and the error message the compiler gives you (the full error message, not just the last line). When asking for help with a computer problem where any error is presented, always post the full text of any and all error messages.

A lot of us answer questions like this from our phones while killing time on bus/subway/etc, and many more of us aren't going to download your ino files, attempt to read your mind w/regard to what board you're using and compile it. Not for free anyway.

The first error I got was that “PI” is defined twice. Comment out the definition.
The rest are warnings where you use ‘&’ in place of ‘&&’.

It is easier to read if you use ‘boolean’, true, and false instead of ‘int’, 1, and 0 for true/false values:

#include <Servo.h>  //arduino library
#include <math.h>   //standard c library

// #define PI 3.141

Servo baseServo;
Servo shoulderServo;
Servo elbowServo;
Servo gripperServo;

int command;

struct jointAngle
  int base;
  int shoulder;
  int elbow;

int desiredGrip;
int gripperPos;

int desiredDelay;

int servoSpeed = 15;
boolean ready = false;

struct jointAngle desiredAngle; //desired angles of the servos

//+++++++++++++++FUNCTION DECLARATIONS+++++++++++++++++++++++++++

int servoParallelControl (int thePos, Servo theServo );

void setup()
  baseServo.attach(9);        // attaches the servo on pin 9 to the servo object

  Serial.setTimeout(50);      //ensures the the arduino does not read serial for too long
  baseServo.write(90);        //intial positions of servos
  ready = false;

//primary arduino loop
void loop()
  if (Serial.available())
    ready = true;
    desiredAngle.base = Serial.parseInt();
    desiredAngle.shoulder = Serial.parseInt();
    desiredAngle.elbow = Serial.parseInt();
    desiredGrip = Serial.parseInt();
    desiredDelay = Serial.parseInt();

    if ( == '\n')               // if the last byte is 'd' then stop reading and execute command 'd' stands for 'done'
      Serial.flush();                     //clear all other commands piled in the buffer
      //send completion of the command

  boolean status1;
  boolean status2;
  boolean status3;
  boolean status4;
  boolean done = false;

  while (!done && ready)
    //move the servo to the desired position
    status1 = servoParallelControl(desiredAngle.base, baseServo, desiredDelay);
    status2 = servoParallelControl(desiredAngle.shoulder,  shoulderServo, desiredDelay);
    status3 = servoParallelControl(desiredAngle.elbow, elbowServo, desiredDelay);
    status4 = servoParallelControl(desiredGrip, gripperServo, desiredDelay);

    if (status1 && status2 && status3 && status4)
      done = true;
  }// end of while

//++++++++++++++++++++++++++++++FUNCTION DEFITNITIONS++++++++++++++++++++++++++++++++++++++++++

int servoParallelControl (int thePos, Servo theServo, int theSpeed )

  int startPos =;        //read the current pos
  int newPos = startPos;
  //int theSpeed = speed;

  //define where the pos is with respect to the command
  // if the current position is less that the actual move up
  if (startPos < (thePos - 5))

    newPos = newPos + 1;
    return false;


  else if (newPos > (thePos + 5))
    newPos = newPos - 1;
    return false;
    return true;

I did not write that sketch. I'm trying to make a toy to see if it will work. I'm trying to learn as I go. Thanks for the help.