Velocidad y dirección con un puente H
Controle un motor de corriente continua con un módulo L298N.
Velocidad y dirección con un puente H es una lección gratuita de Arduino & IoT Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Arduino & IoT Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Arduino & IoT Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
Spinning Both Ways
A plain transistor runs a motor in one direction. To make wheels go forward and back, you need a smarter circuit called an H-bridge. 🔁
Why the H Shape
An H-bridge uses four switches arranged like the letter H. The motor sits in the middle, and flipping pairs of switches reverses the current through it.
Meet the L298N
The L298N is a popular H-bridge module. It can drive two DC motors and handles enough current for hobby robots and small carts.
The Direction Pins
Each motor on the L298N has two direction inputs, called IN1 and IN2. Their combination decides which way the motor turns or whether it stops.
int IN1 = 7, IN2 = 8;
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);Forward and Reverse
Set IN1 HIGH and IN2 LOW to spin one way; swap them to spin the other. The motor simply follows whichever input is higher. ➡️
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW); // forwardReversing the Spin
Flip the two inputs and the current through the motor reverses. This is the magic the H-bridge gives you that a lone transistor cannot.
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH); // reverseStopping the Motor
Set both direction inputs the same, like LOW and LOW, and the motor coasts to a halt because no net current flows through it.
The Enable Pin Controls Speed
Each motor also has an enable pin. Feed it a PWM signal and the duty cycle sets how fast the motor spins, just like dimming an LED.
Speed with analogWrite
Send PWM to the enable pin with analogWrite. A value of 255 is full speed and lower numbers slow the motor down smoothly.
int ENA = 9;
analogWrite(ENA, 180); // about 70% speedPowering the Module
The L298N takes its own motor voltage on a separate terminal. Always tie its ground to the Arduino ground so signals stay in sync.
Two Motors, Full Control
With direction inputs plus PWM enable pins, one H-bridge lets you steer a two-wheel robot at any speed and in any direction. 🤖
Quick Check
On an L298N, what does the enable pin control?
Recap
An H-bridge like the L298N reverses current to change direction, while a PWM enable pin sets the speed. Share ground and you control motors fully. 🚀
Preguntas frecuentes
¿La lección «Velocidad y dirección con un puente H» es gratis?
Sí — el texto completo de «Velocidad y dirección con un puente H» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Arduino & IoT Academy, actualiza a CoddyKit PRO. El curso de Arduino & IoT Academy incluye 4 lecciones en total.
¿Qué aprenderé en «Velocidad y dirección con un puente H»?
Controle un motor de corriente continua con un módulo L298N. Practicas Arduino & IoT Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Arduino & IoT Academy?
No se requiere experiencia previa. Arduino & IoT Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.
¿Cuánto tiempo toma la lección «Velocidad y dirección con un puente H»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Arduino & IoT Academy?
Sí. Cada lección de Arduino & IoT Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Por qué necesita un controlador
- Velocidad y dirección con un puente H
- Conmutar dispositivos de red eléctrica con un relé
- Protegerse contra picos de retorno