I have a following code
#include <Servo.h> //library for servo drive
int MotorAPinA = 9; //pin number for DC drive
int MotorAPinB = 10; //pin number for DC drive
Servo myservo; //create object myservo, class servo from Servo library
void setup() {
// put your setup code here, to run once:
pinMode(MotorAPinA, OUTPUT);
pinMode(MotorAPinB, OUTPUT);
//myservo.attach(6); //pin number for servo output
myservo.write(65);
}
void loop() {
analogWrite(MotorAPinA, 240);
}
This very code works only partly.
If I comment line
myservo.attach(6)
then I got my DC drive working.
If I uncomment this line, my Servo goings crazy (effect looks like myservo.write(0) constantly), until I comment line
analogWrite(MotorAPinA, 240);
and then I got my servo working properly. While myservo.attach(6) is uncommented, DC drive doesn't work (with uncommented analogWrite).
So, basically, I can have or PWM or Servo working simultaneously, but not both
Any ideas? Arduino Uno R3, Arduino 1.8.1.