-1

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);
 }
}
asked Oct 4, 2024 at 12:21

1 Answer 1

0

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

answered Oct 4, 2024 at 14:11
3
  • Thanks!! I found the problem though. Somehow the motors got damaged during soldering. Commented Oct 5, 2024 at 6:09
  • @KnightRiderDutt you said that you tested the motors Commented Oct 5, 2024 at 17:31
  • They were working then. No idea what happened Commented Oct 8, 2024 at 2:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.