3 bipolar stepper motors (LN298)
3 solenoids (NPN)
3 leds
3 buttons
1 POT
INPUTSo, I use a 19V 4.74A for the motor & a 12V 2A for the solenoid. (This sucks)
Arduino is running of USB (for now) [single power source for all in the future]
PartsMotor
https://www.sparkfun.com/products/9238Solenoid
https://www.sparkfun.com/products/10391 H-Bridge
https://www.sparkfun.com/products/9479The motors will rotate to 220 deg and reverse direction back to 0 degrees & repeat ~ 4 times.
Solenoid will be activated while stepper motors are b/w ~120-220 deg and 50-0 deg.
Each motor/solenoid will have a button to perform this process independently of the other.
I use
AccelStepper Library
setAcceleration(8000);
setMaxSpeed(600);
Will i be able to maintain these speeds if I add 2 more motors?
I, also, do not know how I would code this in order to check if the button was pushed on each VOID loop then run the motors or solenoids without forcing a WHILE or a DELAY?
I'm sure there is a way, since i believe the accelstepper library uses the clock for delays. I just need a bit of guidance.
void loop()
{
buttonState = digitalRead(ButPin);
if (buttonState == HIGH) {
// button has been pushed
digitalWrite(LedPin, HIGH);
stepper.setCurrentPosition(0); //this will set the current position to 0
stepper.enableOutputs (); //Give current to the motor
stepper.moveTo(1); //performs an action so motor gets some juice
stepper.run(); //performs an action so motor gets some juice
delay(10);//letting the motor get wild for 1 step
for(int i=0; i<=3; i++) {
stepper.moveTo(dist); //moves motor to dist like 220 degrees
while (stepper.currentPosition() != dist){
stepper.run();
if (stepper.currentPosition() >= 80){
digitalWrite(SolPin, HIGH);
}else{
digitalWrite(SolPin, LOW);
}
}
digitalWrite(SolPin, LOW);
delay(100); //letting the sol fall
if(i==3)
break;
stepper.moveTo(-0);
while (stepper.currentPosition() != 0){
stepper.run();
if (stepper.currentPosition() <= 50){
digitalWrite(SolPin, HIGH);
}else{
digitalWrite(SolPin, LOW);
}
}
digitalWrite(SolPin, LOW);
delay(100);//letting the sol fall
}
delay(10);
digitalWrite(SolPin, LOW);
stepper.disableOutputs ();
}
else {
blinkLED();
}
//Serial.print("irPin = ");
// Serial.println(val);
}