stepper/servo combo problems

i have an easydriver+stepper connected to an arduino.
only step pin is attached to pin 48 (mega).
if i connect a servo to any PWM pin > stepper STEP pin starts getting pulses > stepper rotates constantly.

i trimmed down the code, to the bare minimum to reproduce.
mybe i need some filtering ?

#include <Servo.h> 
Servo myservo; 

void setup() { 
  myservo.attach(9);
} 
void loop() { }

power via modified ATX psu.
servo gets 5V and stepper 12V, arduino is powered via usb, ground is shared.
before i connected the servo i had no problems.
i also tried powering the servo via the easydriver regulated 5v output. same deal.

bump?

Misterious? Are you just using this code and the stepper is turning?

I had some trouble using servo.h and stepper.h at the same code.

Was not working together.

I made some test.

This code is working and no stepping of the motor - Servo is doing what is should too.

#include <Servo.h> 

//int zaehler;
Servo servo1;

int dirpinh = 2;
int steppinh = 3;
int sleeph = 4;
int ms1h = 8;
int stepstateh = LOW;
int velh = 200;

int i;
long previousMicros;

void setup() {  
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");
  servo1.attach(9);  // attaches the servo on pin 9 to the servo object 
  pinMode(dirpinh, OUTPUT);
  pinMode(steppinh, OUTPUT);
  pinMode(sleeph, OUTPUT);
  pinMode(ms1h, OUTPUT);
  digitalWrite(sleeph, LOW);
}

void loop(){
  if (Serial.available() > 0) {
  
    int inByte = Serial.read(); 
    
  switch (inByte) { 
    case 'a':
      Serial.println("Motor_left");
      digitalWrite(ms1h, LOW);
      digitalWrite(dirpinh, LOW);
      digitalWrite(sleeph, HIGH);
        i = 3200;
        while(i > 1)       // Iterate for 3200 flip / flops makes 1cycle with  my 1.8deg motor.
            {
              if (micros() - previousMicros > velh)
                {
                  previousMicros = micros();
                  if (stepstateh == LOW)
                      stepstateh = HIGH;
                  else
                      stepstateh = LOW;
                      digitalWrite(steppinh, stepstateh);    
                    i--;  
               }
            }  
        digitalWrite(sleeph, LOW);    
      break;   
    
    case 'g':
     servo1.write(200);
     Serial.println("Servo_left");
     break;
    
    case 'h':
     Serial.println("Servo_middle");
     servo1.write(90);              // tell servo to go to position in variable 'pos' 
     break;
    
    case 'j':
     servo1.write(0);
     Serial.println("Servo_right");    
     break; 
       
    default:
      Serial.println("micro");  
      } //switch fuer eingegebene Daten    
    } //serial serial available ende
  } //loop

When I was using delay for the stepping pin the servo was not working properly.

Here I mixed the ( Dan Thompson: EasyDriver 4.2 Tutorial ) tutorial of Dan Thomson with the blink without delay example and the servo.h example.

Hardware is Arduino 2009 - Stepper - Easydriver and some Servo.

Hope that helps!

[code][code][code][code][/code][/code][/code][/code]