Loading
Loading
IoT Lab content is currently available in Arabic only. We're working on an English version.
عرض بالعربية →How to build a robot car and why we need the L298N.
9V battery goes into the 12V terminal of L298N. Connect L298N's GND to Arduino's GND (very important). Motor wires to OUT1 and OUT2. Control pins IN1 and IN2 to Arduino pins 8 and 9.
const int in1 = 8;
const int in2 = 9;
void setup() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
}
void loop() {
digitalWrite(in1, HIGH); digitalWrite(in2, LOW); // دوران يمين
delay(2000);
digitalWrite(in1, LOW); digitalWrite(in2, LOW); // توقف
delay(1000);
digitalWrite(in1, LOW); digitalWrite(in2, HIGH); // دوران يسار
delay(2000);
}Not connecting the shared GND wire between L298N and Arduino. Without this common ground, the control signals won't be understood and motors will spin randomly or not at all.