Hello everyone, greetings, could someone help me with this error, I'm a little new to this world

// Seguidor Solar

#include <Servo.h>
//Definiendo Servomotor
Servo servo1;
int servomotor = 0;
int servomotorLS = 160;
int servomotorLI = 20;
//Asigando fotoresisenticas
int fsup = 0; // Fotoresistencia superior
int finf = 1; // Fotoresistencia inferior

void setup (){

motor.attach(3);
servo1.attach(9);
servo1.write(0);
delay(500);
}

void loop()
{
servomotor = servo1.read();
//Entradas de valores de las fotoresistencias
int sup = analogRead(fsup);
int inf = analogRead(finf);

if (sup < inf)
{
servo1.write(servomotor +1);
if (servomotor > servomotorLS)
{
servomotor = servomotorLS;
}
delay(10);
}
else if (inf < sup)
{
servo1.write(servomotor -1);
if (servomotor < servomotorLI)
{
servomotor = servomotorLI;
}
delay(10);
}
else
{
servo1.write(servomotor);
}
delay(10);
}
void AbrirPuerta(){
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
motor.write(9);
delay(500);
motor.write(20);
delay(500);
motor.write(30);
delay(500);
motor.write(40);
delay(500);
motor.write(50);
delay(500);
motor.write(60);
delay(500);
motor.write(70);
delay(500);
motor.write(80);
delay(500);
motor.write(90);
delay(500);
motor.write(100);
delay(500);
motor.write(110);
delay(500);
motor.write(120);
delay(500);
motor.write(130);
delay(500);

digitalWrite(4,HIGH);
digitalWrite(5,LOW);
delay(5000);
}
void CerrarPuerta(){
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
motor.write(130);
delay(500);
motor.write(120);
delay(500);
motor.write(110);
delay(500);
motor.write(100);
delay(500);
motor.write(90);
delay(500);
motor.write(80);
delay(500);
motor.write(70);
delay(500);
motor.write(60);
delay(500);
motor.write(50);
delay(500);
motor.write(40);
delay(500);
motor.write(30);
delay(500);
motor.write(20);
delay(500);
motor.write(10);
delay(500);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
}

Which error? You didn't attach any error messages in your question.

Please read and use the topic "How to get the best out of this forum",
Post code the proper way, not like text.
Describe the problem.
Post error report jf there is one.

In function 'void setup()':
15:3: error: 'motor' was not declared in this scope
In function 'void AbrirPuerta()':
55:3: error: 'motor' was not declared in this scope
In function 'void CerrarPuerta()':
89:3: error: 'motor' was not declared in this scope

The code looks like you combined it from multiple sketches.
You have two servomotor objects in your code - servo1 and motor
But in reality, how many motors do you use in in the project?

estoy usando 2 servos

You have defined only one servo in the code:

You have to define motor as servo and attach it to defined pin.

disculpa ¿podrias modificar el codigo por mi'?. la verdad soy muy nuevo en esto

I will not rewrite your code for you. You pasted together programs you do not understand. If you are new, learn by doing smaller project, like these:

https://docs.arduino.cc/built-in-examples/

1 Like

muchisimas gracias