Guys I need to control 2 stepper motors to rotate continuously I have the 1.4 ramps and the arduino mega 2560 but the motors don't work I don't know how to program the arduino correctly.
OBS: the connection of the motors is correct, the drivers are good and the motors also when I upload a 3d printer firmware the motors work ok it's a matter of programming
#include
#include
#include
#include
#include
#include
#include
#include
#define X_ENABLE_PIN 38
// define números de pinos
const int stepPin = 26 ;
const int dirPin = 28 ;
const int stepPinx = 38 ;
const int dirPinx = 36 ;
void setup ( ) {
// Define os dois pinos como Saídas
pinMode ( stepPin, OUTPUT ) ;
pinMode ( dirPin, OUTPUT ) ;
pinMode ( stepPinx, OUTPUT ) ;
pinMode ( dirPinx, OUTPUT ) ;
}
void loop() {
// permite que o motor se mova em uma direção particular
digitalWrite(dirPin, HIGH);
digitalWrite(dirPinx, HIGH);
// faz 200 pulsos para fazer uma rotação de ciclo completo
for(int x = 0; x < 200; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
for(int y = 0; y < 100; y++) {
digitalWrite(stepPinx,HIGH);
delayMicroseconds(500);
digitalWrite(stepPinx,LOW);
delayMicroseconds(500);
}}}