Arduino Code for L9110 Dual DC Motor Controller Module
In this tutorial, we will explore how to control two DC motors using the L9110 dual motor controller module with an Arduino. This project will enable you to manage the direction and speed of each motor, allowing for versatile applications such as robotics and automation. By the end of this guide, you will have a clear understanding of how to wire the components and write the code necessary to get your motors running smoothly. If you need clarification, be sure to check the video (in video at 00:00).
Hardware Explained
The L9110 dual DC motor controller module allows you to control two motors simultaneously. It features two H-bridge circuits, which enable you to reverse the polarity of the motor voltage. This means you can easily change the direction of each motor by toggling the control pins. The module has four key pins: two for each motor to control the direction of rotation. When you set one pin high and the other low, the motor spins in one direction; reversing the pin states will make it spin in the opposite direction. This flexibility is essential for applications like robotics, where you need precise control over motor movements.Datasheet Details
| Manufacturer | STMicroelectronics |
|---|---|
| Part number | L9110 |
| Logic/IO voltage | 2.5–5.5 V |
| Supply voltage | 2.5–12 V |
| Output current (per channel) | 1 A |
| Peak current (per channel) | 2 A |
| PWM frequency guidance | 10 kHz |
| Input logic thresholds | 0.8 V (low), 2.0 V (high) |
| Voltage drop / RDS(on) / saturation | 0.3 V at 1 A |
| Thermal limits | 150 °C |
| Package | DIP-16 |
| Notes / variants | Commonly used in small robotics projects. |
- Ensure proper heat-sinking for continuous operation.
- Keep PWM signals below 10 kHz for optimal performance.
- Use decoupling capacitors near power connections to minimize noise.
- Beware of reversed polarity connections; they can damage the module.
- Always check the rated current limits to avoid overheating.
Wiring Instructions
To wire the L9110 dual DC motor controller module with an Arduino, start by connecting the power pins. Connect the VCC pin on the L9110 to the 5V output on the Arduino, and connect the GND pin to one of the Arduino's ground pins. Next, for motor A, connect the A1A pin to digital pin 2 on the Arduino and the A1B pin to digital pin 3. Then, for motor B, connect the B1A pin to digital pin 8 and the B1B pin to digital pin 9. Ensure that the motors are properly connected to their respective outputs on the L9110 module.
Code Examples & Walkthrough
In the setup function, we need to define the control pins as outputs. This is essential for the Arduino to control the motor directions effectively:void setup() {
pinMode(B1A,OUTPUT);// define pin as output
pinMode(B1B,OUTPUT);
pinMode(A1A,OUTPUT);
pinMode(A1B,OUTPUT);
delay(3000);
}
This code snippet sets up the motor control pins, ensuring that the Arduino can send signals to the L9110 module.
The main loop of the program controls the motors by calling the `motorA` and `motorB` functions with different parameters to change directions:
void loop() {
motorA('R');// Turn motor A to RIGHT
delay(2000);
motorA('L');// Turn motor A to LEFT
delay(2000);
motorA('O');// Turn motor A OFF
delay(2000);
...
}
In this excerpt, the motors are made to turn right and left, with delays in between to observe the changes in direction.
The `motorA` function is defined to control motor A based on the input direction:
void motorA(char d) {
if(d =='R'){
digitalWrite(A1A,LOW);
digitalWrite(A1B,HIGH);
} else if (d =='L'){
digitalWrite(A1A,HIGH);
digitalWrite(A1B,LOW);
} else {
digitalWrite(A1A,LOW);
digitalWrite(A1B,LOW);
}
}
This function checks the provided direction and sets the control pins accordingly to rotate the motor in the desired direction or turn it off.
Demonstration / What to Expect
When you run the code, you should see the motors alternating between left and right rotations. The delays allow you to observe the changes in direction clearly. Be cautious of common pitfalls like reversed connections, which can lead to unexpected behavior or damage to the components. Additionally, ensure that your power supply is adequate for the motors you are using (in video at 00:00).
107-Arduino code for an L9110 dual DC motor controller module
Idioma: C++
Copiado!
Coisas que você pode precisar
-
Amazonas
Recursos e referências
Ainda não há recursos.
Arquivos📁
Arquivo Fritzing
-
L9110 H-bridge Motor driver module
application/zip0.04 MB