I can get LEDs to fade properly using PWM on pins 44-46 on the Mega2560 when I don't have a servo attached, but once I "attach" the servo in the code, then PWM pins 44-46 don't work for PWM. They can still work with digitalWrite, but not with analogWrite.
This is the code:
#include <Servo.h>
Servo myservo;
int led = 46;
void setup() {
myservo.attach(3);
pinMode(led, OUTPUT);
analogWrite(led, 60);
}
void loop() {}
If I comment out the "myservo.attach(3);" line, then PWM works for the LED pin. Otherwise the LED stays off. Why would PWM on pins 44-46 stop working once the servo is attached?