Hi, So the project I want to do is control 2 stepper motors to move in x and y axis without using arduino library.
I want to move my motor in x axis for 100 steps from left to right and at 100th step move my motor in y axis one step up and again move x axis motor from right to left (from 101 to 200) and repeat till 600 steps.
I'm not sure where to incorporate the y axis movement in the algorithm.
Sorry if this isn't enough information, I'm a beginner in Arduino challenging myself to learn as much as I can. Any help will be appreciated.
Also: I do not want to use any arduino library. The motor driver: l293d and stepper motor just a basic bipolar, I don't have any datasheet for it.
#define A 8
#define A_bar 9
#define B 10
#define B_bar 11
#define y 100
int xdir= 1; //initial direction-->Forward
int xdir1; //direction change variable-->Reverse
int count = 1; //Starting step
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
pinMode(A, OUTPUT);
pinMode(A_bar, OUTPUT);
pinMode(B, OUTPUT);
pinMode(B_bar, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//finding end point
if (count%100 == 0) {
//change direction
xdir1 = xdir*(-1);
//y-axis move one step
digitalWrite(A, HIGH);
digitalWrite(A_bar, LOW);
digitalWrite(B, HIGH);
digitalWrite(B_bar, LOW);
delay (y);
Serial.println(xdir1);
}
//direction control
for (count =1; count<=600;count++)
if (xdir == 1)
{
digitalWrite(A, HIGH);
digitalWrite(A_bar, LOW);
digitalWrite(B, HIGH);
digitalWrite(B_bar, LOW);
delay (y);
Serial.println(count);
}
if (xdir == -1)
{
digitalWrite(A, HIGH);
digitalWrite(A_bar, LOW);
digitalWrite(B, LOW);
digitalWrite(B_bar, HIGH);
delay (y);
//Serial.println (count);
}
count++;
Serial.println (count);
delay (1000);
}
I used this to check initially in the serial monitor. It prints from 1 to 600 but I'm not sure how to see that change in direction.
Any help would be appreciated. Thank you