The dc motor will move forwards, stop then move backwards at increasing speed infinitely. You do not need to include the switch and the capacitor as they are optional but they increase the functionality of the project. We have also connected a capacitor with the two terminals of the dc motor so that there are no abrupt voltage spikes. This way we can turn the driver on and off without connecting and disconnecting wires manually. We are using a slider switch connected with the 9V battery supply which is very helpful in cutting the power supply. You can use any other power source as you please. As we can use any power source ranging from 6-12V, we will incorporate a 9V battery in our case. This is why we will be using an external power source for the dc motor. The dc motor is rated at 6-12V, and requires a large amount of current to start. You can choose appropriate GPIO pins when connecting the Raspberry Pi Pico board and the driver module together. GP3 and GP2 are connected with IN1 and IN2 respectively. Thus, ENA will set the speed and IN1 and IN2 will set the spinning direction of the motor. We will be using motor A output pins to control this motor. Raspberry Pi Pico with L298N and dc motor connection diagram Now, as we have seen how to control the dc motor through the motor driver, let us do a demonstration by incorporating our Raspberry Pi Pico board. Interfacing DC Motor & L298N motor Driver with Raspberry Pi Pico Motor B is also controlled in a similar way. For backwards motion, IN1 should be HIGH and IN2 should be LOW. In order for motor A to spin forward, IN1 should be LOW and IN2 should be HIGH. Otherwise, when both the inputs are LOW (ground) state or both are in HIGH state then the motor stops. IN1Īs seen from the table, whenever one of the inputs is in a HIGH state (5V) then the motor will spin. The table below shows the logic signals required for the appropriate spinning action for motor A. IN1 and IN2 control motor A’s spinning direction whereas IN3 and IN4 control motor B’s spinning direction. Through these input pins we can determine whether to move the dc motor forward or backwards. Let us now see the details behind controlling the dc motor through the L298N module. Motor A having voltage between 5-35V, will be connected through these two terminals.Ĭontrolling DC motors through L298N module and MicroPython This pin controls the speed of the motor B by enabling the PWM signal. They control the spinning direction for that particular motor. This pin controls the speed of the motor A by enabling the PWM signal. If jumper is intact, then it acts as an output pin. Will be used only if the 5V enable jumper is not intact. This pin supplies the power (5V) for the internal circuit (L298N IC). It is imprinted with +12V on board but can be powered between 6-12V. This is the pin which supplies power to the motor. We will be using the same Thonny IDE as we have done previously when we learned how to blink and chase LEDs in MicroPython here: Additionally, you should have a running Integrated Development Environment(IDE) to do the programming. MicroPython Control a DC Motor using L298N Driver with ESP32 and ESP8266īefore we start this lesson, make sure you are familiar with and have the latest version of Python3 installed in your system and set up MicroPython in your Raspberry Pi Pico.Interface L298N DC Motor Driver Module with Arduino.Interfacing L298N DC Motor Driver Module with ESP8266 NodeMCU.Interface L298N DC Motor Driver Module with ESP32.We have similar guides for ESP32, ESP8266, and Arduino using Arduino IDE: We will introduce you to the L298N motor driver module and then we will use it to learn some basic control of the dc motor including start, stop, backward and forward motion through our Raspberry Pi Pico board. In this user guide, we will learn how to control a DC motor with Raspberry Pi Pico in MicroPython by using an L298N motor driver.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |