Digital pins 8-11 malfunctioning?

Hi guys quick question, I've been working on a project using servos and potentiometers with an arduino mega board 2560 (not an off-brand one either) and I've found that the pins 8-11 make my servos behave incredibly erratically. I've tested all pins and they work perfectly so I'm not sure what the issue is.

It doesn't bother me much as the mega board has like 50 pins so 3 faulty ones aren't an issue, but I'm just concerned about the prospect of this issue potentially spreadings, and/or me repeating the same mistake that caused it and killing other pins.

Any advice would be appreciated! <33

More detail please

For starters, how are the servos powered and what sketch are you running ?

Servos are powered with deep-cycle 6v 12Ah battery and I'm running this sketch:

// Libraries
#include <Servo.h>
#include <Stepper.h>
#include <AccelStepper.h>

//Define inputs
int Pval1;
int Pval2;
int Pval3;
int butt1 = 0;
int butt2 = 0;
int butt3 = 0;
int butt4 = 0;
int butt5 = 0;
int butt6 = 0;

// Define servos
Servo servo1;
int servo1_angle;
Servo servo2;
int servo2_angle;

// Define mini stepper
Stepper Mstep = Stepper(2048, 8, 10, 9, 11);

// Define steppers
AccelStepper step1 = AccelStepper(1, 3, 2);
int step1_pos;

void setup() {
  //Setup inputs
  pinMode(A3, INPUT);
  pinMode(A4, INPUT);
  pinMode(A5, INPUT);
  pinMode(A6, INPUT);
  pinMode(A7, INPUT);
  pinMode(A8, INPUT);

  //Setup servos
  servo1.attach(8);
  servo2.attach(9);

  //Setup mni stepper
  Mstep.setSpeed(10);

  //Setup steppers
  step1.setMaxSpeed(1000);
  step1.setAcceleration(100.0);

  Serial.begin(9600);
}

void loop() {
  //Read inputs
  Pval1 = analogRead(A0);
  Pval2 = analogRead(A1);
  Pval3 = analogRead(A2);
  butt1 = digitalRead(A3);
  butt2 = digitalRead(A4);
  butt3 = digitalRead(A5);
  butt4 = digitalRead(A6);
  butt5 = digitalRead(A7);
  butt6 = digitalRead(A8);

  //Servo controls
  servo1_angle = map(Pval1, 0, 1023, 0, 179);  // Servo 1, Pot 1
  Serial.print(", Servo 1 angle: ");
  Serial.print(servo1_angle);
  servo1.write(servo1_angle);

  servo2_angle = map(Pval2, 0, 1023, 0, 179);  // Servo 2, Pot 2
  Serial.print(", Servo 2 angle: ");
  Serial.print(servo2_angle);
  servo2.write(servo2_angle);

  //Stepper controls
  if (butt1 == HIGH) {  //Mini stepper,  Buttons 1 & 4
    Mstep.step(-50);
    Serial.println(", Mini stepper left");
  } 
  else if (butt4 == HIGH) {
    Mstep.step(50);
    Serial.println(", Mini stepper right");
  } 
  else {
    Mstep.step(0);
    Serial.println(", Mini stepper still");
  }
}

Also it's like in-progress so it might be messy mb

Hi, @immyimmy

Forget your code for the moment.
Write some simple code that JUST has the servo control, leave out the stepper code.
If you wrote your code in stages, you should already have this simple code.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

I don't know too much about this stuff. I see 8 and 9 for the servo and 8 and 9 for the micro stepper. Might there be a conflict?

And further as TomGeorge said above, strip it down and test the servos.

Don't you think there might be a conflict using the same pins for the mini stepper motor and the servos?

< edit > sorry, missed the previous post pointing this out

No worries :wink:

Ughh that's so dumb of me you're right it is the stepper motor, I thought I had checked all interferences in the code but I guess not.

I'm usually more careful before I post cause stuff but it's real late where I am so ig my brain wasn't working right sorrry. Thanks for the help anyways guys!

Yeah, I think we knew that when you said that pins 8-11 was 3 pins!