hi i am new to the subject ;)
when I put this code get error and can not do.
int opened=0;
int outerSensor=0; int inne
rSensor=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);
d}
igitalWrite(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 d
etects 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(); ti
meout=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) { clo
seDoor(); 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 pn
eumatic solenoids...timings are
slightly different and tuned to the door characteristics
void openDoor() {
digitalWrite(3, HIGH); delay(1100); digitalWrite(3, LOW);
}
void closeDoor()
{
digitalWrite(2, HIGH); delay(750); digitalWrite(2, LOW);
}
assistance please