I have been having a problem with reversing my dc motor. The motor is just running in the same direction and my program is not charging the direction as dictated by the sketch.
Someone to help me with the code to run the motor forward for some time the reverse for sometime and the stop the motor!
This is the code am using;
#define motorpin1 2
#define motorpin2 3
#define motorpin3 4
#define motorpin4 5
#define enablepin 8
void setup() {
pinMode(motorpin1, OUTPUT);
pinMode(motorpin2, OUTPUT);
pinMode(motorpin3, OUTPUT);
pinMode(motorpin4, OUTPUT);
// set speedPin high so that motor can turn on:
digitalWrite(enablepin, HIGH);
}
void loop() {
digitalWrite(motorpin1, LOW);
digitalWrite(motorpin2, HIGH);
digitalWrite(motorpin3, LOW);
digitalWrite(motorpin4, HIGH);
delay(1500);
digitalWrite(motorpin1, LOW);
digitalWrite(motorpin2, LOW);
digitalWrite(motorpin3, LOW);
digitalWrite(motorpin4, LOW);
delay(1500);
digitalWrite(motorpin1,HIGH);
digitalWrite(motorpin2,LOW);
digitalWrite(motorpin3,HIGH);
digitalWrite(motorpin4,LOW);
}