I was facing a problem for a month. I am trying to use L298N card for control my DC motor but when I connect the enable pin to my arduino, motor starts to sound like zz but it doesn't work. When I try use 5V of card to enable pin(short circuit on card) it works well. What should I do for control the card with my arduino?
#define rightmotor1 6 //in3 on pin6 controls one side of motor
#define rightmotor2 7 //in4 on pin7 controls other side of motor
#define rightmotorEn 9 //enB on pin9 controls speed of motor
void setup() {
//set all outputs
pinMode(rightmotor1,OUTPUT);
pinMode(rightmotor2,OUTPUT);
pinMode(rightmotorEn,OUTPUT);
}
void loop() {
digitalWrite(rightmotor1,HIGH);//Set in3 high for voltage
digitalWrite(rightmotor2,LOW);//set in4 low for ground
analogWrite(rightmotorEn,100);//set pwm control for speed
}
if the Enable from this Module HIGH-Active or LOW-Active?
is it LOW-Active, you Write: analogWrite(rightmotorEn, 0) for enable the motor.
is it HIGH-Active, you write: analogWrite(rightmotorEn, 255) for enable the motor.
If you applied an analogWrite value of 255 and the motor still buzzes, you have a hardware problem. Could be wiring, or could be the power supply is no good.
Where is 5V supplied to the L293D module? I see nothing on the terminal.
I just noticed: I don't see a GND connection between the Arduino and the L293 module. only the + 5V can be seen.
It is essential to connect the GND of the Arduino and the L293 module so that the signals have a reference potential.
digitalWrite(rightmotor1,HIGH); //I supply 5V there. Or did I misunderstand your question ?
digitalWrite(rightmotor2,LOW);
analogWrite(rightmotorEn,100);
My Friends told me that its about hardware as well. I am going to try another arduino when I go to University.