Your breadboard should have a split down the middle, like a gap, and the IC chip should straddle it nicely with half of its pins on either side, so it runs parallel with the board. The first thing to do is put the L293D chip on the breadboard. The pictures above probably look like a confusing jumble of wires, but don't worry. Now that we know what will be going on, it's time to start wiring it up. 2 of the output pins will be for the inputs on the IC, and one will be for the Enable. So, on the Raspberry Pi, we'll be using 3 GPIO output pins on the GPIO board, one 3.3V power supply, and one grounding pin.
L298n motor driver specification raspberry pi code#
That way we keep the code simpler, and less things can go wrong. Since the IC has an Enable pin that controls its On/Off state, we can leave both inputs set to run and just modulate the Enable pin, and the IC will only put out power according to the duty we set in the Enable pin. That's how we'll control the direction, but what about speed? We talked about PWM right? So we'll just Pulse Width Modulate both inputs, right? We could, but it would be too complicated. If both inputs are True or both are False, the motor will not run. And if we want it to spin backwards, we'll set input 1 to 'False" or 'LOW' and input 2 to 'True' or "HIGH'. So, in our code, with the Enable pin On, if we want the motor to spin forward, we'll set input 1 to 'True' or 'HIGH', and input 2 to 'False' or 'LOW'. The L293D motor IC uses two pins referred to as inputs to sense the desired direction of the output, and another pin called Enable to sense On/Off.
To see how PWM looks as an output, refer to the diagram above.
The amount of time the voltage is high is called the 'duty' or 'duty cycle', and whatever percentage that is will be the percentage of power the motor runs on. What PWM means is just controlling the amount of time a voltage is on by flipping between high and low for a set amount of time. The way we'll control the speed of the motor is by using a python module called PWM. We'll be using very simple python commands, and no prior computer programming knowledge will be necessary. Python is a computer programming language, comparable to Javascript or C++. We're using them as outputs, to send signals to the L293D IC Chip, which is just a chip used to control DC motors. GPIO stands for "General Purpose Input/Output", which means these pins can either send electrical signals to drive hardware or receive them and read sensor data. In this project, we're using python scripts run on a Raspberry Pi to set GPIO outputs to an L293D motor controller IC and run a DC motor in either direction at any speed.įirst things first a Raspberry Pi is an open-source credit card sized computer with 40 open GPIO pins. If you don't care about how this is done and just want to do it without learning, skip to Step 3.** The jumper should not be placed when the power supply is greater than 12V and separate 5V should be given through 5V terminal to power the internal circuitry.ĮNA & ENB pins are speed control pins for Motor A and Motor B while IN1& IN2 and IN3 & IN4 are direction control pins for Motor A and Motor B.**This step is all background info. When the power supply is less than or equal to 12V, then the internal circuitry will be powered by the voltage regulator and the 5V pin can be used as an output pin to power the microcontroller. The L298N Motor Driver module consists of an L298 Motor Driver IC, 78M05 Voltage Regulator, resistors, capacitor, Power LED, 5V jumper in an integrated circuit.ħ8M05 Voltage regulator will be enabled only when the jumper is placed. Note: Complete technical details can be found in the L298N Datasheet linked at the bottom of this page. Related Components: LM298 Motor Driver IC, 78M05 Voltage Regulator, Capacitors, Resistors, Heat Sink Supplies power for the switching logic circuitry inside L298N ICĪlternate Driver Modules: TMC2209, DRV8825, A4988, L9110S, DRV8711 Used to control the spinning direction of Motor B Used to control the spinning direction of Motor A L298N Module can control up to 4 DC motors, or 2 DC motors with directional and speed control. This module consists of an L298 motor driver IC and a 78M05 5V regulator. This L298N Motor Driver Module is a high power motor driver module for driving DC and Stepper Motors.