Geschwindigkeit und Richtung mit einer H-Brücke
Steuern Sie einen Gleichstrommotor mit einem L298N-Modul.
Geschwindigkeit und Richtung mit einer H-Brücke ist eine kostenlose Arduino & IoT Academy-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Arduino & IoT Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
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. 🚀
Häufig gestellte Fragen
Ist die Lektion „Geschwindigkeit und Richtung mit einer H-Brücke“ kostenlos?
Ja — der vollständige Text von „Geschwindigkeit und Richtung mit einer H-Brücke“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Arduino & IoT Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Geschwindigkeit und Richtung mit einer H-Brücke“?
Steuern Sie einen Gleichstrommotor mit einem L298N-Modul. Du übst Arduino & IoT Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Arduino & IoT Academy zu starten?
Keine Vorkenntnisse erforderlich. Arduino & IoT Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.
Wie lange dauert die Lektion „Geschwindigkeit und Richtung mit einer H-Brücke“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Arduino & IoT Academy-Lektion Code schreiben und ausführen?
Ja. Jede Arduino & IoT Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Warum Sie einen Treiber benötigen
- Geschwindigkeit und Richtung mit einer H-Brücke
- Netzgeräte mit einem Relais schalten
- Vor Rückschlagspitzen schützen