I was trying to use the motor driver, but the motors aren't spinning for some reason.
I am sure the motors are working; I tried and tested them. I can't understand if there is a problem with the code, motor driver or the Arduino board.
Arduino board used: Arduino UNO R3
Here is the code:
char data; //Serial
void setup() {
// put your setup code here, to run once:
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()) {
data = Serial.read();
Serial.println(data);
}
if (data == '1') {
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
digitalWrite(7,LOW);
}
}
1 Answer 1
I do not see any problem with your code. However, the code must be compatible with the circuit connections. Please check your whole setup part by part. Check the motor driver with a direct power supply. See if you get the expected output. The motor may not spin due to insufficient voltage and/or current too. So, check your power supply with a multimeter. Since you are sending commands through the serial monitor, check if there has been any baud rate mismatch. You can also check this tutorial for some help: https://www.theengineeringprojects.com/2017/04/dc-motor-direction-control-arduino.html
-
Thanks!! I found the problem though. Somehow the motors got damaged during soldering.KnightRiderDutt– KnightRiderDutt10/05/2024 06:09:45Commented Oct 5, 2024 at 6:09
-
@KnightRiderDutt you said that you tested the motorsjsotola– jsotola10/05/2024 17:31:39Commented Oct 5, 2024 at 17:31
-
They were working then. No idea what happenedKnightRiderDutt– KnightRiderDutt10/08/2024 02:38:12Commented Oct 8, 2024 at 2:38