Go Down

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

Azlan

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
  s1.writeMicroseconds(1500);
}

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

retrolefty

simple misspelling.

change #inlude <Servo.h>

to #include <Servo.h>

Lefty

Azlan

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

retrolefty


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.  ;)

Lefty

WizenedEE

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