0Pricing
Arduino & IoT Academy · Aula

Velocidade e direção com uma ponte H

Controle um motor DC com um módulo L298N.

Velocidade e direção com uma ponte H é uma aula grátis de Arduino & IoT Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Arduino & IoT Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Arduino & IoT Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em 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); // forward

Reversing 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); // reverse

Stopping 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% speed

Powering 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. 🚀

Perguntas Frequentes

A aula “Velocidade e direção com uma ponte H” é grátis?

Sim — o texto completo de “Velocidade e direção com uma ponte H” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Arduino & IoT Academy, atualize para CoddyKit PRO. O curso de Arduino & IoT Academy inclui 4 aulas no total.

O que vou aprender em “Velocidade e direção com uma ponte H”?

Controle um motor DC com um módulo L298N. Você pratica Arduino & IoT Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Arduino & IoT Academy?

Nenhuma experiência prévia é necessária. Arduino & IoT Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.

Quanto tempo leva a aula “Velocidade e direção com uma ponte H”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Arduino & IoT Academy?

Sim. Cada aula de Arduino & IoT Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Por que você precisa de um controlador
  2. Velocidade e direção com uma ponte H
  3. Acione dispositivos da rede elétrica com um relé
  4. Proteja-se contra picos de retorno
← Voltar para Arduino & IoT Academy