Servomotor and 2 Stepper motors programme

Hello!
I've been trying for weeks to make work 2 stepper motors and 1 servomotor with an arduino UNO board and an adafruit motor Shield, because I have to do an school project with them. I've tried so many different programmes but I only can make work the servo. I've connected the steppers in motor pins (one in M1 and M2 and the other one in M3 and M4).
I can't find the problem, but I suppose that the programme I'm using is not the correct one. Can anybody give me a programme which can make work these three components at the same time? I don't mind the speed or the sequence, I can modify it if I need it, but I only want to make it work together.

The motors I'm using are these: Stepper motor - NEMA-17 size - 200 steps/rev, 12V 350mA : ID 324 : $14.00 : Adafruit Industries, Unique & fun DIY electronics and kits and the shield is this one: Motor/Stepper/Servo Shield (Version 2) | Adafruit Shield Compatibility Guide | Adafruit Learning System

Thank you very much and sorry for my English.

I've tried so many different programmes

So post one. Along with a schematic showing how you have wired it up and information about the power supply you are using for the motors.

That stepper motor, as its info page mentions will need 2 full H-bridges to power it,
you need to use one H-bridge for one winding (red/yellow) and the other for the other
(green/brown-grey)

You don't say exactly which motor shield alas - there are two at least from Adafruit,
and they are very different.

Grumpy_Mike:

I've tried so many different programmes

So post one. Along with a schematic showing how you have wired it up and information about the power supply you are using for the motors.

I've used this to move only one stepper (it doesn't work too):

#include <AFMotor.h>


AF_Stepper motor(200, 2);


void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");

  motor.setSpeed(50);  // 10 rpm   

  motor.step(100, FORWARD, SINGLE); 
  motor.release();
  delay(1000);
}

void loop() {
  motor.step(100, FORWARD, SINGLE); 
  motor.step(100, BACKWARD, SINGLE); 

  motor.step(100, FORWARD, DOUBLE); 
  motor.step(100, BACKWARD, DOUBLE);

  motor.step(100, FORWARD, INTERLEAVE); 
  motor.step(100, BACKWARD, INTERLEAVE); 

  motor.step(100, FORWARD, MICROSTEP); 
  motor.step(100, BACKWARD, MICROSTEP); 
}

And this to move one stepper and the servomotor (it only make work the servo):

#include <AFMotor.h>
#include <Servo.h> 

// DC motor on M2
AF_DCMotor motor(2);
// DC hobby servo
Servo servo1;
// Stepper motor on M3+M4 48 steps per revolution
AF_Stepper stepper(200, 2);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor party!");
  
  // turn on servo
  servo1.attach(10);
   
  // turn on motor #2
  motor.setSpeed(200);
  motor.run(RELEASE);
}

int i;

// Test the DC motor, stepper and servo ALL AT ONCE!
void loop() {
  motor.run(FORWARD);
  for (i=0; i<255; i++) {
    servo1.write(i);
    motor.setSpeed(i);  
    stepper.step(1, FORWARD, INTERLEAVE);
    delay(3);
 }
 
  for (i=255; i!=0; i--) {
    servo1.write(i-255);
    motor.setSpeed(i);  
    stepper.step(1, BACKWARD, INTERLEAVE);
    delay(3);
 }
 
  motor.run(BACKWARD);
  for (i=0; i<255; i++) {
    servo1.write(i);
    motor.setSpeed(i);  
    delay(3);
    stepper.step(1, FORWARD, DOUBLE);
 }
 
  for (i=255; i!=0; i--) {
    servo1.write(i-255);
    motor.setSpeed(i);  
    stepper.step(1, BACKWARD, DOUBLE);
    delay(3);
 }
}

I'm connecting them like the foto shows

Thanks

MarkT:
That stepper motor, as its info page mentions will need 2 full H-bridges to power it,
you need to use one H-bridge for one winding (red/yellow) and the other for the other
(green/brown-grey)

You don't say exactly which motor shield alas - there are two at least from Adafruit,
and they are very different.

I don't know how to use H-bridges :~
I'm using this connections, is it anything wrong?

Thanks

As Mark says:-

You don't say exactly which motor shield alas - there are two at least from Adafruit,
and they are very different.

Can you provide a link to the motor shield you are using.
Also can you provide a link to that stepping motor library you are using.

Can you provide a link to the motor shield you are using.

The shield is the one which appears in the foto here Motor/Stepper/Servo Shield (Version 2) | Adafruit Shield Compatibility Guide | Adafruit Learning System

Also can you provide a link to that stepping motor library you are using.

And the library is this https://github.com/adafruit/Adafruit-Motor-Shield-library/zipball/master

Clearly the wrong library - you have version 2 of the motor shield, if you follow the
tutorial pages (which you should have done from the start) it very clearly points you
to this library:

MarkT:
Clearly the wrong library - you have version 2 of the motor shield, if you follow the
tutorial pages (which you should have done from the start) it very clearly points you
to this library:
Install Software | Adafruit Motor Shield V2 | Adafruit Learning System

It works perfectly, I was going crazy!
Karma for you, thanks a lot!!! :slight_smile: