I'm quite new to Arduino, and I got a smart car project kit from an event near me. I ended up deleting the program on the Arduino Uno, and did something else. I came back to the car and I've tried to make my motors move (there are four) but I can only seem to get the motors to move in 1 direction, forward. No matter what I try I cannot get them to move backwards. They just move forward, wait 2 seconds, move forward, wait 2 seconds, loop. Can someone please help me, and inform me if I can use a better library?
Here is the current code I have:
#include <Stepper.h>
const int stepsPerRevolution = 200;
Stepper myStepper = Stepper(stepsPerRevolution, 0, 2, 3, 1);
void setup() {
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(A0, OUTPUT);
myStepper.setSpeed(100);
}
void loop() {
analogWrite(A0, 180);
myStepper.step(200);
delay(2000);
analogWrite(A0, 0);
myStepper.step(-200);
delay(2000);
}