Hot answers tagged

1

const int p1=7;//pwm pin for motor 1 const int p2=8; //pwm pin for motor 2 PWM pins on a '168 are 3,5,6,9,10,11


1

The ENA/ENB (enable A/B) pins have to be at HIGH level (either hardwired or set by an mcu). There exist lots of different driver boards (mostly based on the same ICs) which sometimes don't provide this enable pin, but they are "enabled" by default. You didn't tell us which board you use, but you'll know.


1

The specified minimum voltage for the motors is 2.5 volts higher than the logic supply. You need to use a separate supply for the motor that is higher than the logic power.


1

Well, your wiring is OK, but I think the 'digitalWrite(enB, HIGH); in the loop() code is causing your problem. You don't want to try to use the same pin for both digital and analog functions. I wired up a Uno here with your setup and a L298N, and got a motor to run fine with the following sketch that doesn't use the loop() at all - it does everything in ...


Only top voted, non community-wiki answers of a minimum length are eligible