Control motors with the L298N H-bridge
FunduinoPublished on
Zwei Gleichstrommotoren in beide Richtungen drehen lassen
You need this
L298N motor driver - H-bridge for 2 DC motors, 5-35 V
3,22 € *Item no. F23107161About the product — L298N motor driver - H-bridge for 2 DC motors, 5-35 V
TT gear motor - 3-6 V, 1:90, 200 rpm, all-metal gearbox, single shaft
3,80 € *Item no. F23109195About the product — TT gear motor - 3-6 V, 1:90, 200 rpm, all-metal gearbox, single shaft
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
830-point Breadboard - solderless breadboard for Arduino
2,90 € *Item no. FUN-1010553About the product — 830-point Breadboard - solderless breadboard for Arduino
Breadboard cables male-female - 40 pieces, 20 cm
1,74 € *Item no. FUN-1010554About the product — Breadboard cables male-female - 40 pieces, 20 cm
All 5 parts together 22,78 € *Ready to ship immediately · Delivery time: 1-3 business days
* All prices include statutory VAT, plus shipping costs.
Pinout
Circuit diagram
Example sketch
Example sketch
// Gleichstrommotor 1
int GSM1 = 10;
int in1 = 9;
int in2 = 8;
// Gleichstrommotor 2
int GSM2 = 5;
int in3 = 7;
int in4 = 6;
void setup()
{
pinMode(GSM1, OUTPUT);
pinMode(GSM2, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void loop()
{
digitalWrite(in1, HIGH); // Motor 1 beginnt zu rotieren
digitalWrite(in2, LOW);
analogWrite(GSM1, 200); // Motor 1 soll mit der Geschwindigkeit "200" (max. 255) rotieren
digitalWrite(in3, HIGH); // Motor 2 beginnt zu rotieren
digitalWrite(in4, LOW);
analogWrite(GSM2, 200); // Motor 2 soll ebenfalls mit der Geschwindigkeit "200" (max. 255) rotieren
delay(2000);
digitalWrite(in1, LOW); // Durch die Veränderung von HIGH auf LOW (bzw. LOW auf HIGH) wird die Richtung der Rotation verändert.
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(2000);
digitalWrite(in1, LOW); // Anschließend sollen die Motoren 2 Sekunden ruhen.
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(2000);
}Rate the instructions