In a robot, I'm using a servo for steering and a L298N Motor Controller for the little drive motor.
In the attached program, when I rem out the "myservo.attach(3);" line, the motor works fine.
When I put that line in, the drive motor won't run.
This is an abbreviated sketch just to show the problem. This test does not move the servo.
I'm using an Arduino UNO R3
I suppose I'm just missing something stupid but I've looked and looked at it and am not seeing it.
// Robot that follows light
// L298N Dual Motor Controller Drive Motor
#include <Servo.h> // Does steering
Servo myservo; // create servo object to control a servo
// motor one
int enA = 10; // assign pins to motor controller
int in1 = 9;
int in2 = 8;
void setup()
{
// The "myservo.attach(3);" line makes the motor controller and motor not work.
// Rem out the following line and the motor works.
myservo.attach(3); // attaches the servo on pin to the servo object
// set all the motor control pins to outputs
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// turn on motor A Forward
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
// set speed to 110 out of possible range 0~255
analogWrite(enA, 110);
Serial.println("Moving Forward ******************************************");
while (1) { } // just stop here for testing
}