I had already typed this all out once before i lost connection...so i'll make it breif and not fancy this time.
hardware:
adruino
adafruit motor shield
2 slow dc motors
1 adrafruit stepper
purpose:
trying to get this code to simply move the 1st DC motor forward , backwards, and pause.
then the stepper to do the same...
then the 2nd dc motor to do the same...
right now the2 dc motors are on ports 1 and 2
the stepper is one ports 3 and 4
both the 2dc motors together and then the stepper worked fine with the code when alone...
but when i tried to combine the stepper with the dc's nothing seems to work correctly. one of the dc motors
keeps turning many more times then it should and that's about it.
I will adjust it later, but if we could just get this basic code working then things would be much easier...
Thanks so much for taking time to look!
heres the code so far (its just combining the AF motortest and AF stepper test):
[Edit - moderator - use code button when submitting large blocks of code ]
Code: Select all
// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!
#include <AFMotor.h>
AF_DCMotor motor1(2), motor3(1);
AF_Stepper motor2(48, 3);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
motor2.setSpeed(10); // 10 rpm
// turn on motor
motor1.setSpeed(200);
motor1.run(RELEASE);
// turn on motor
motor3.setSpeed(200);
motor3.run(RELEASE);
}
void loop() {
Serial.println("Single coil steps");
motor2.step(500, FORWARD, SINGLE);
motor2.step(500,BACKWARD,SINGLE);
Serial.print("tick-");
motor1.run(FORWARD);
motor1.setSpeed(250);
delay(500);
Serial.print(" pause---");
motor1.run(RELEASE);
delay(500);
Serial.print("tock---");
motor1.run(BACKWARD);
motor1.setSpeed(250);
delay(500);
Serial.print("puase1-");
motor1.run(RELEASE);
delay(5000);
Serial.print("pause2--");
motor3.run(RELEASE);
delay(5000);
Serial.print("rotate 1-");
motor3.run(FORWARD);
motor3.setSpeed(250);
delay(500);
Serial.print("pause2-");
motor3.run(RELEASE);
delay(500);
Serial.print("rotate 2--");
motor3.run(BACKWARD);
motor3.setSpeed(250);
delay(500);
Serial.print("pause2-");
motor1.run(RELEASE);
delay(5000);
Serial.print("pause2--");
motor3.run(RELEASE);
delay(5000);
}