Go Down

Topic: 'Servo' does not name a type (Read 1 time) previous topic - next topic


I keep getting 'Servo' does not name a type message everytime I tried to compile my code

Here is my code:
Code: [Select]
#inlude <Servo.h>

Servo s1;

int F1 = 0;

void setup() {
  s1.attach(2); // attaches the servos

void loop() {
  int FV1 = analogRead(F1);
  // usable range for flex sensors
  if (FV1 < 200) FV1 = 200;
  else if (FV1 > 460) FV1 = 460;

  // servo timer map
  int timer1 = map(FV1, 0, 1023, 0, 2000);

Any idea to fix this problem?
Arduino Uno
Software: Arduino 1.0.3


simple misspelling.

change #inlude <Servo.h>

to #include <Servo.h>



I just went full retard :smiley-eek:, shame on me


I just went full retard :smiley-eek:, shame on me

No, it happens to all of us (well maybe not to PaulS), I call them brain farts. Some coding problems just have to have another set of eyeballs applied.  ;)



Newer version of gcc gives a better error message:
Code: [Select]

build-uno/tmp.cpp:1:2: error: invalid preprocessing directive #inlude
build-uno/tmp.cpp:3:1: error: 'Servo' does not name a type
build-uno/tmp.cpp: In function 'void setup()':
build-uno/tmp.cpp:8:3: error: 's1' was not declared in this scope
build-uno/tmp.cpp: In function 'void loop()':
build-uno/tmp.cpp:20:7: warning: unused variable 'timer1' [-Wunused-variable]

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131