Re: Controls for a project

You are perfectly entitled to go your own way - don't apologize.

I think this will work - I may hook it up to a few servos to check. Obviously you need to add in appropriate setup() stuff. And you probably need more suitable starting values for the angles.

It would probably also be a good idea to have a special button that causes all the parts to move to the start position before you switch off the system - but I'm sure that can wait a bit.

byte mainArmAngle = 90;
byte jibAngle = 90;
byte bucketAngle = 90;
byte slewAngle = 90;

void setup() {
 // all the setup stuff

}

void loop() {
  readPotentiometers();
  moveServos();
}

void readPotentiometers() {
  int potVal;
  potVal= analogRead(pinForMainArmPot);
  if (potVal< 500) {
     mainArmAngle = mainArmAngle + 2;
  }
  if (potVal> 520) {
     mainArmAngle = mainArmAngle - 2;
  }
  
  potVal= analogRead(pinForJibPot);
  if (potVal< 500) {
     jibAngle = jibAngle + 2;
  }
  if (potVal> 520) {
     jibAngle = jibAngle - 2;
  }
  
  potVal= analogRead(pinForBucketPot);
  if (potVal< 500) {
     bucketAngle = bucketAngle + 2;
  }
  if (potVal> 520) {
     bucketAngle = bucketAngle - 2;
  }
  
  potVal= analogRead(pinForSlewPot);
  if (potVal< 500) {
     slewAngle = slewAngle + 2;
  }
  if (potVal> 520) {
     slewAngle = slewAngle - 2;
  }
}

void moveServos() {
  mainArmServo.write(mainArmAngle);
  jibServo.write(jibAngle);
  bucketServo.write(bucketAngle);
  slewServo.write(slewAngle);
}

...R