Hola soy nuevo en el tema de programacion en arduino, y necesitaria ayuda para hacer realidad un proyecto.
el proyecto seria programar el arduino uno para que se abra y se cierre una puerta corredera para los gatos.
encontre esto que seria lo ideal pongo enlaces..
Pero ahora al poner el codigo en el programa me sale error en la linia (int countOut=0; int inSense=0; int outSense=0; int entering=0;)
y no doy palo al agua para solucionar esto..
si alguien me pudiera ayudar?
venias con un 10 como calificación (muchos no saben presentar debidamente su problema) salvo el comentario de que los enlaces debes ponerlos usando el icono eslabon
este
Tu código parace ser este
Veamos que encuentro. Pondré // ERROR y lo corregiré
int opened=0;
int outerSensor=0;
int innerSensor=0;
int countIn=0;
int countOut=0;
int inSense=0;
int outSense=0;
int entering=0;
int exiting=0;
int cycleLock=0;
int timeout=0;
int delayLoop=0;
void setup(void) {
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
}
void loop() {
outerSensor=analogRead(A1); //delay(500);
innerSensor=analogRead(A0);
Serial.println("a0");
Serial.println(innerSensor);
//delay(1000);
//Serial.println("a1");
// Serial.println(outerSensor);
// If outer sensor detects something, wait for 20 positives before setting flag
if (outerSensor > 300) {
countOut++;
if (countOut > 20) {
outSense=1;
}
} else countOut=0;
// Same again for the inside sensor, but with different sensitivity
if (innerSensor >300) {
countIn++;
if (countIn > 20) {
inSense=1;
}
} else countIn=0;
if (timeout > 0)
timeout--;
// If the sensor is triggered for the first time, open the door
if ((outSense == 1) && (timeout == 0)) {
entering=1;
openDoor();
} else
if ((inSense == 1) && (timeout == 0)) {
exiting=1;
openDoor();
}
// This one is for entering from outside to inside - wait until the inner sensor is triggered before closing...
if (entering > 0) {
entering++;
if (inSense == 1) {
closeDoor();
timeout=200;
entering=0;
exiting=0;
}
}
// Or until the timeout is reached
if (entering > 1000) {
entering=0;
exiting=0;
closeDoor();
timeout=200;
}
// Same again but the other way around...
if (exiting > 0) {
exiting++;
if (outSense == 1) {
closeDoor();
timeout=200;
exiting=0;
entering=0;
}
}
if (exiting > 1000) {
exiting=0;
entering=0;
closeDoor();
timeout=200;
}
inSense=0;
outSense=0;
}
// The open and close door routines - these trigger a relay which
//in turn supplies 24V to the pneumatic solenoids...timings are ***** ERROR FALTAN //
//slightly different and tuned to the door characteristics ***** ERROR FALTAN //
void openDoor() {
digitalWrite(3, HIGH); delay(1100); digitalWrite(3, LOW);
}
void closeDoor() {
digitalWrite(2, HIGH);
delay(750);
digitalWrite(2, LOW);
}
se me había escapado un error mas pero ya esta. Ya compila. No se si funciona. Eso te lo dejo a ti.