I am using analogWrite() in my code. Everything works fine when I am not using the servo library. In other words, everything is fine when I disable this line //servo_9.attach(9); If I enable this line, the PWM will be wrong and weird. Any idea why the Tinkercad simulator is acting weird?
#include <Servo.h>
int led =9;
Servo servo_9;
void setup() {
servo_9.attach(9);
Serial.begin(9600);
}
void loop() {
for(int n=0;n<255;n++){
analogWrite(led,n);
delay(5);
}
}
This video shows what is happening: click here
The documentation for the servo library clearly states.