I am doing a little school project. I have an arduino uno, sg90 servo, 1 small dc motor(the little ones on the kits) and L298N motor controller.
I have a function to move the motor and a function to move the servo(sweep demo). They work perfect when I do one or the other. When I call one after the other, the dc motor never runs.,
I am using pin 7,8,9 for motor controller and 6 for the servo. I am running the motor controller from a 12V power adapter and the arduino from the USB cable.
Basically, if I comment the servo code, the motor works.
On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12.
So you need to use a different pin to provide PWM for your motor speed