Trouble with PWM pins

Hello everyone and thank you in advance for any help you may give.

Bellow is mycode. The problem is that myservo.attach(10) causes one of my two motors to not turn. As long as I don’t include that in my code I have no problems with either motor. Also I can’t get the PWM function on pins 3, 5, and 6 to work; not for motors or servos. What am I doing wrong?

#include <Servo.h> 

int LMotorD_PIN = 8;  
int RMotorD_PIN = 12; 
int RmotorPWM_PIN = 9; 
int LmotorPWM_PIN = 11;


Servo myservo;
 
void setup() 
{   
  pinMode(LMotorD_PIN, OUTPUT);
  pinMode(RMotorD_PIN, OUTPUT);
  
  myservo.attach(10);
  myservo.write(5);
  delay(2000);
} 
 
void loop() 
{ 

   digitalWrite(RMotorD_PIN, HIGH);
   digitalWrite(LMotorD_PIN, HIGH);
   analogWrite(LmotorPWM_PIN, 100);
   analogWrite(RmotorPWM_PIN, 100);

}

Read this :slight_smile:
http://arduino.cc/en/Reference/Servo

Also see this post: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232572239

Thank you very much you two. I totaly missed the part where servos can only be attached to pins 9 & 10.