code problem

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

d}
igitalWrite(4,HIGH);
}

What's that?

if (outSense == 1) { clo
seDoor();

And that?

It's mainly just line breaks. How did you get your code in such a state?

code is a project of the web ::slight_smile:

AWOL:

d}

igitalWrite(4,HIGH);
}



What's that?



if (outSense == 1) { clo
seDoor();



And that?

I'm very new and do not know much about programming

Where did you get this code from?

ardujet:
I'm very new and do not know much about programming

It looks like you need to spend a bit of time studying.

Look at the Arduino Reference section so you can see what functions are available. That should help you to see that, for example igitalWrite(4,HIGH); should be

digitalWrite(4,HIGH);

And from that you might see the pattern that clo and seDoor(); are not meant to be on different lines.

You could also try a more effective way of getting code from the web without errors.

...R

thanks for the help, the code is this website, but not if I have to keep creating the code, if not complete or incomplete.

what I want is to close and open a sliding door for the cat. :wink:

the code is this website, but not if I have to keep creating the code, if not complete or incomplete.

I'm sorry, I don't understand what you mean by that.

AWOL:
I'm sorry, I don't understand what you mean by that.

I get error on line

int countOut=0; int inSense=0; int outSense=0; int entering=0;

Where did you get this code from?

AWOL:
Where did you get this code from?

This is the web.

Have you tried contacting Ashis Mohapatra and Aman Anand?

Put that code aside and try working through some of the examples provided in the IDE.

ardujet:
what I want is to close and open a sliding door for the cat. :wink:

Search this Forum (using Google) - there are lots of Threads about doors or flaps for pets/dogs/cats.

...R

OK I've taken out the silly line break issues. But you should start learning about how this code works (if indeed it even does.

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

KenF!!! thank you very much for the help and put the code in order.

really appreciate the time you took to look at this code. You must understand that I have started on this recently and I'm still very green.
try to learn by watching people work. Thank you !!!! :wink:

Thank you all for help!!