Hi all, I'm trying to get my arduino duemilanuove to output a clock (ledpin high and low) while it is moving three steppers with the stepper library.
So this steppers are moving in sequence and I would like arduino to continuously output a usable clock, without waiting for the void loop to finnish each time.
here's my code:
#include <Stepper.h>
#define motorSteps 48 // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 7
#define motorPin2 8
#define motorPin3 9
#define motorPin4 10
#define motorPin5 11
#define motorPin6 12
// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2);
Stepper myStepper2(motorSteps, motorPin3,motorPin4);
Stepper myStepper3(motorSteps, motorPin5,motorPin6);
int ledPin = 1; // the number of the LED pin
void setup() {
// set the motor speed at 60 RPMS:
myStepper.setSpeed(120);
myStepper3.setSpeed(120);
myStepper2.setSpeed(120);
pinMode(ledPin, OUTPUT);
// Initialize the Serial port:
Serial.begin(9600);
}
void loop() {
// Step forward 100 steps:
Serial.println("Forward");
myStepper2.step(70);
myStepper3.step(70);
myStepper.step(70);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
}
i've tried this (in void loop) with the same results
void loop() {
// Step forward 100 steps:
Serial.println("Forward");
myStepper2.step(70);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
myStepper3.step(70);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
myStepper.step(70);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200);
}
Any help would be fantastic, thanks!