9/2/2023 0 Comments L293d 2 dc motors arduino![]() ![]() Here notice the function analogWrite(ENA1, 255) we are using the PWM feature of pin 5. void loop()ĪnalogWrite(ENA1, 255) //Sets speed of motor using PWMĭigitalWrite(IN1, HIGH) //Input 1 is turned onĭigitalWrite(IN2, LOW) //Input 2 is turned offĭigitalWrite(IN1, LOW) //Both inputs are turned offĭigitalWrite(IN1, LOW) // Input 1 is offĭigitalWrite(IN2, HIGH) // Input 2 is on In the setup we set the purpose of the declared pins, in this case all pins are set as output. These pins will make the motor start, stop and change direction depending on which pin is HIGH/LOW. Next there are pins 8 and 9 connected to pin IN1 and IN2 respectively. This will help us control the speed of our motor. Here the ENA1 pin is connected to pin 5 of arduino as it is a PWM enabled pin. Coding:įirst we define pins that we will be using. now we can write code to control the motor. This will power our motor and the IC itself. Connect Pin 8 and 16 of the IC to +ve terminal of 9v battery. If you don’t do this, the motor will not work. Pin 4,5,12,13 of IC are connected to GND of Arduino and battery. Here we have connected the input pins of IC to arduino: ![]() For this tutorial we will control only one motor using arduino. In the above image you can see the pinouts of the IC. You can find motor driver modules and shields online which help control multiple motors but for this tutorial we will stick with minimum for learning the basics. So we use a motor driver like L293D or L298N. We cannot connect a motor directly to arduino as it will fry the board instantly. It has 2 H-bridges which helps control the speed and direction of motors. L293D is a motor drive IC which can be used to control 2 DC motors or 1 Stepper motor. Let me explain about this IC in a simple and short term. So every thing in the list might look familiar except “ L293D“. Breadboard with Jumpers ( Amazon US / Amazon EU).Buying product from those links helps us run this blog without any charges on you. So without wasting any more time, let’s get right into it.ĭisclaimer: This blog contains Amazon Affiliate links. In this tutorial we will see, how to control a DC Motor, it’s speed and direction using arduino and L293D motor driver IC. Most common thing you find in these toys are DC motors. If you are anything like me then you probably have disassembled tons of toys to figure that out. Are you a beginner and want to get into robotics? Then you must have many questions in mind like “How to make the robot move?” or “which tools to use to make the robot move?”. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |