I have made a sumobot with an arduino, an afmotor shield and a 4-pin ping sensor when I upload my code it keeps giving me this error: "'Servo' does not name a type" here is my code.

  • 2
    Try #include <Servo.h> – Mikael Patel Jan 23 '16 at 16:18
  • As a kindness to people reading your question and trying to answer please include your code in the question rather than linking to it. Also, including the code ensures that it will stay available. – dlu Jan 23 '16 at 19:30
  • ok, but the insert code thing kept glitching out and just showing garbled text in varying bold and code – parseguy Jan 24 '16 at 0:55
  • also im using 2 paralax servos (large) – parseguy Jan 24 '16 at 0:55
  • Possible duplicate of Why does it say "Servo" does not name a type – Roberto Lo Giacco Sep 8 '16 at 0:59

You are creating Servo objects instead of AF_DCMotor objects. Change this:

Servo leftMotor;
Servo rightMotor;

to this:

AF_DCMotor leftMotor(1);   // Change these numbers to the correct motor numbers
AF_DCMotor rightMotor(2);  // you are using on the shield

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.