0

Lib is imported, but compiler don't find it

I have imported the lib Servo.h, using the interface but the compiler can't find it and execute my code.

1:19: error: 'Servo' was not declared in this scope

1:19: note: suggested alternative: 'Servo_h'

1:28: error: expected primary-expression before 'int'

1:35: error: expression list treated as compound expression in initializer [-fpermissive] In function 'int iniciar_servo(Servo, int)':

14:35: error: 'int iniciar_servo(Servo, int)' redeclared as different kind of symbol 1:5: note: previous declaration 'int iniciar_servo' In function 'void setup()':

22:34: error: 'iniciar_servo' cannot be used as a function 23:34: error: 'iniciar_servo' cannot be used as a function exit status 1

My code:

#include <Servo.h>

const int pin_serv_esq = 3;
const int pin_serv_dir = 5;

Servo esq;
Servo dir;

int sensorValue = 0;

int iniciar_servo(Servo s, int pin) {
s.attach(pin);
s.write(0);
return 0;
}

void setup()
{
iniciar_servo(esq, pin_serv_esq);
iniciar_servo(dir, pin_serv_dir);

pinMode(A0, INPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
}

void loop()
{
// read the value from the sensor
sensorValue = analogRead(A0);
Serial.println(sensorValue);
sensorValue = map(sensorValue, 0, 1023, 0, 180);
Serial.println(sensorValue);

delay(1000); // Wait for sensorValue millisecond(s)
}

0 comments

Please sign in to leave a comment.