Hey all,
I have recently started my luck at integrated circuits and electronics, and my first project is to make a Dagu rover 5 powered by a 4 motor controller and an arduino uno. for some reason one of the motors only works when I have it in HIGH output mode. I don’t know if I did something wrong with the coding or if it is the motor that doesn’t work. this is my coding: (I’m currently working on debugging mostly void backwards and void forwards)
const int E1 = 9; //M1 Speed Control //PWM input, green
const int E2 = 10; //M2 Speed Control
const int E3 = 11; //M3 Speed Control
const int E4 = 6; //M4 Speed Control
const int M1 = 12; //M1 Direction Control //digital input, yellow
const int M2 = 4; //M2 Direction Control
const int M3 = 8; //M3 Direction Control
const int M4 = 2; //M4 Direction Control
void setup()
{
pinMode(E1, OUTPUT);
pinMode(E2, OUTPUT);
pinMode(E3, OUTPUT);
pinMode(E4, OUTPUT);
pinMode(M1, OUTPUT);
pinMode(M2, OUTPUT);
pinMode(M3, OUTPUT);
pinMode(M4, OUTPUT);
}
void loop()
{
straight();
delay(4000);
stop();
while(true){}
}
void slowleft()
{
analogWrite (E1, 255);
analogWrite (E2, 0);
analogWrite (E3, 255);
analogWrite (E4, 0);
digitalWrite (M1, HIGH);
digitalWrite (M3, HIGH);
digitalWrite (M4, HIGH);
digitalWrite (M2, HIGH);
}
void slowright()
{
analogWrite (E1, 0);
analogWrite (E2, 255);
analogWrite (E3, 0);
analogWrite (E4, 255);
digitalWrite(M2, HIGH);
digitalWrite(M4, HIGH);
}
void fastleft()
{
analogWrite (E1, 255);
digitalWrite (M1, HIGH);
analogWrite (E2, 255);
digitalWrite (M2, HIGH);
analogWrite (E3, 255);
digitalWrite (M3, HIGH);
analogWrite (E4, 255);
digitalWrite (E4, HIGH);
}
void fastright()
{
analogWrite (E1, 255);
digitalWrite (M1, LOW);
analogWrite (E2, 255);
digitalWrite (M2, LOW);
analogWrite (E3, 255);
digitalWrite (M3, LOW);
analogWrite (E4, 255);
digitalWrite (E4, LOW);
}
void straight()
{
analogWrite (E1, 255);
digitalWrite (M1, LOW);
analogWrite (E2, 255);
digitalWrite (M2, LOW);
analogWrite (E3, 255);
digitalWrite (M3, HIGH);
analogWrite (E4, 255);
digitalWrite (E4, LOW);
}
void backwards()
{
analogWrite (E1, 255);
digitalWrite (M1, HIGH);
analogWrite (E2, 255);
digitalWrite (M2, HIGH);
analogWrite (E3, 255);
digitalWrite (M3, LOW);
analogWrite (E4, 255);
digitalWrite (E4, HIGH);
delay (6000);
}
void stop()
{
analogWrite (E1, 0);
analogWrite (E2, 0);
analogWrite (E3, 0);
analogWrite (E4, 0);
}
Thanks all for the help!