I'm relatively new to coding in Arduino and I can't figure out why this code returns an error:
#include <Servo.h>
Servo myServo; // This brings an error
void setup(){
myServo.attach(9);
myServo.write(0);
}
void loop(){
myServo.write(90);
delay(1000); // This brings an error
myServo.write(-90);
delay(1000); // This brings an error
}
This code supposedly moves a servo motor back and forth. I used a simulator (Tinkercad) to test this code and it worked perfectly fine! But for some reason I can't upload it onto the Arduino.
I think it has something to do with the Libraries but, as I said before, I am pretty new to this kind of stuff.
Can you tell us the error so we don't have to guess. If there is an error, there is a "copy error message" button at the right hand side above the output pane. Click it to copy the errors to the clipboard and next paste them here in a reply.
PS
Instructions above are for the normal IDE and might not apply to IDE 2.0 beta.