Go Down

Topic: Please help me for the connections and coding for the dc motor using IC l298 (Read 260 times) previous topic - next topic

rohit04ramos

i am trying to connect dc motor to arduino uno for motor rotation using ic l298 and facing problems as i am not able to perform it correctly after the connections nothing is happening just a red light is continuosly on. i am beginner.
help me through it. i am uploading the code on this forum please help me out as soon as possible.
                   
const int pwm = 3 ;  //initializing pin 3 as pwm
const int in_1 = 9;
const int in_2 = 10 ;

//For providing logic to L298 IC to choose the direction of the DC motor

void setup()
{
pinMode(pwm,OUTPUT) ;   //we have to set PWM pin as output
pinMode(in_1,OUTPUT) ;  //Logic pins are also set as output
pinMode(in_2,OUTPUT) ;

}

void loop()
{
//For Clock wise motion , in_1 = High , in_2 = Low

digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,LOW) ;
analogWrite(pwm,255) ;

/*setting pwm of the motor to 255
we can change the speed of rotaion
by chaning pwm input but we are only
using arduino so we are using higest
value to driver the motor  */

//Clockwise for 3 secs
delay(3000) ;     
//For brake
digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,HIGH) ;
delay(1000) ;

//For Anti Clock-wise motion - IN_1 = LOW , IN_2 = HIGH
digitalWrite(in_1,LOW) ;
digitalWrite(in_2,HIGH) ;
delay(3000) ;

//For brake
digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,HIGH) ;

delay(1000) ;
}

vinceherman

Can you show us a wiring diagram?
Pencil, paper and a camera are good enough if you give proper detail (like pin numbers)
See this handy image guide.

Can you give a link to the motor?
What is your power source?

rohit04ramos

Connect 5V and ground of the IC to 5V and ground of Arduino.
Connect the motor to pins 2 and 3 of the IC.
Connect IN1 of the IC to pin 8 of Arduino.
Connect IN2 of the IC to pin 9 of Arduino.
Connect EN1 of IC to pin 2 of Arduino.
Connect SENS A pin of IC to the ground.
Connect the Arduino using Arduino USB cable and upload the program to the Arduino using Arduino IDE software.
Provide power to the Arduino board using power supply, battery or USB cable

slipstick

That's not a diagram. There are no details of the motor. And no details of "power supply, battery".

Steve

rohit04ramos

help me out plz

vinceherman

OP's pics so that we don't have to download them.  By the way, this was covered in the image guide that I linked you to.








slipstick

I can't see any external power supply or battery. It looks as though the L298 and motor may be powered from the Arduino 5V pin which is a bad idea. Particularly with an L298 which is probably dropping over 2V leaving less than 3V across the motor.

What pin(s) on the L298 is the power connected to? Do you actually have a power supply or battery? If so what are their specifications? Voltage, current, battery type and size etc.

Steve

jremington

Always use a separate power supply for motors. A 9V, 1 Amp power brick may work with that little motor.

Do not forget to connect all the grounds together.

Go Up