Codey OnlineArduino- & ESP32-Komponentenbibliothek › L298N Motor Driver Board
L298N Motor Driver Board
Aktoren

L298N Motor Driver Board

Das L298N Motor Driver Board ist ein Dual-H-Brücken-Motortreiber, der zwei DC-Motoren steuert (Richtung und Geschwindigkeit). Verwende IN1–IN4 für die Drehrichtung der Motoren und ENA/ENB für die Aktivierung der PWM-Drehzahlregelung; schließe die Motoren an OUT1–OUT4 an. Die Logikseite wird typischerweise über einen 5V-Pin versorgt, während die Motorversorgung von einer höheren Spannung wie 12V kommt (gemeinsame Masse erforderlich).

Breite: 40.9 mm

Pinbelegung — L298N Motor Driver Board

Pin Signal Beschreibung
IN1 digital Logic direction input for motor A H-bridge.
GND ground Common ground for motor supply and logic control signals.
IN2 digital Logic direction input for motor A H-bridge.
IN3 digital Logic direction input for motor B H-bridge.
IN4 digital Logic direction input for motor B H-bridge.
OUT1 power Motor A output terminal 1 — connect one lead of the left motor.
OUT2 power Motor A output terminal 2 — connect the other lead of the left motor.
ENA enable Enable/PWM input for motor A speed control; high enables OUT1/OUT2.
ENB enable Enable/PWM input for motor B speed control; high enables OUT3/OUT4.
OUT3 power Motor B output terminal 1 — connect one lead of the right motor.
OUT4 power Motor B output terminal 2 — connect the other lead of the right motor.
12V power-high Motor supply input for the L298N power stage, typically 7–12 V.
VCC power 5 V logic supply/output depending on regulator jumper configuration.
12V power-high Motor supply input for the L298N power stage, typically 7–12 V.

Beispielschaltplan — L298N Motor Driver Board

Von Nach Kabel
board:D5 x1:ENA green
board:D8 x1:IN1 blue
board:D9 x1:IN2 yellow
board:D10 x1:IN3 purple
board:D11 x1:IN4 cyan
board:GND x1:GND black
board:5V x1:VCC red

Arduino-Beispielcode — L298N Motor Driver Board

Dieses Beispiel wurde für das arduino-uno geschrieben und kompiliergeprüft. Codey Online passt es für jedes andere unterstützte Board an.

// Canonical example for the L298N Left Motors module
// Drives the two motor channels forward, reverse, and stop using PWM on ENA.

const int ENA = 5;   // PWM speed control
const int IN1 = 8;   // Motor A direction
const int IN2 = 9;   // Motor A direction
const int IN3 = 10;  // Motor B direction
const int IN4 = 11;  // Motor B direction

void stopMotors() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  analogWrite(ENA, 0);
}

void forward(int speedValue) {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  analogWrite(ENA, speedValue);
}

void reverse(int speedValue) {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  analogWrite(ENA, speedValue);
}

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  Serial.begin(9600);
  Serial.println("L298N left motors example starting...");
  stopMotors();
}

void loop() {
  Serial.println("Forward");
  forward(180);
  delay(2000);

  Serial.println("Stop");
  stopMotors();
  delay(1000);

  Serial.println("Reverse");
  reverse(180);
  delay(2000);

  Serial.println("Stop");
  stopMotors();
  delay(1000);
}

Ähnliche Komponenten

A4988 Stepper Driver

A4988 Stepper Driver

DRV8825 Driver Board

DRV8825 Driver Board

Left DC Motor

Left DC Motor

NEMA17 Stepper Motor

NEMA17 Stepper Motor

Bau dein Arduino- oder ESP32-Projekt mit AI

Beschreib einfach, was du bauen willst. Codey Online schreibt den Code, zeichnet den Schaltplan, kompiliert alles und flasht dein Board direkt aus dem Browser.

Kostenlos starten