Re: Controls for a project

That won't work because you need a different potVal for every servo. Also the existing potVal is a local variable in readPotentiometers AND even if it was global it is updated after your new version.

Put the button code into its own function (keep your code nicely organized) - and use it like this (calling readButton() from loop())

void readButton() {
   if (digitalRead(buttonPin) == LOW {   // assumes active LOW
        buttonPressed = true;                        // needs to be a global variable
   }
}


void readPotentiometers() {
  int potVal;
  if (buttonPressed() {
       buttonPressed = false;
       for (byte n = 0; n < 4; n++) {
           angle[n]  = whateverYouWant;
       }
  }
  else {
  for (byte n = 0; n < 4; n++) {
    potVal = analogRead(potPin[n]);
    // etc

...R

Thank You, It worked