Bi-directional secure access vehical gate

Hi people, Hope everythis is good for all of you. for me im going nuts. using basic i can right up some script no problem but this seems to be verry diferent and quite confusing.
I live in a campground and we employ a security gate for after hours access and exit. We have had unothorised people in the park making quite a mess and i foolishly offered to use an Arduino as a controller to our problem.
("xxxxxx" was not declaired in this scope) is keeping me up at night. I dont seem to be getting an answer i can understand. I am a total greenhorn to this Arduino.
A breef discription as to how it is supose to work and then i will past the nightmerish code for the world to see, hopfull to get some direction on this.
so
Gate: we have three inground sencing loops and one security keypad. the three loops i call. Exit, Enter, Presence the way it is working now is, exit opens gate presence keeps gate open, enter keeps gate open while exiting. the way unothorised access is gained is if a vehical creeps up close enough to the presence pad in the middle of the gate it will oppen due to the fact that this pad is there for safty sake, the second way is that a guest on the inside will pull up to the exit pad oppening the gate for the unothorised party and backing up as they follow then in.
I may be way off with this so called code but its all i got at the moment so. Hear it is...

#include <ezButton.h>

ezButton pade (3);
ezButton padp (4);
ezButton padx (5);
ezButton padk (6);
const int gatepin = 8;
const int slightpin = 9;
const int nlightpin = 10;

void setup() {
Serial.begin (9600);
pade.setDebounceTime(40);
padp.setDebounceTime(40);
padx.setDebounceTime(40);
padk.setDebounceTime(40);
  pinMode(gatepin, OUTPUT);
  pinMode(slightpin, OUTPUT);
  pinMode(nlightpin, OUTPUT);

}

void loop() {


pade.loop();
padp.loop();
padx.loop();
padk.loop();


if(padx.isPressed());
if(pade.isPressed());
if(padp.isReleased());
pad   digitalWrite(nlightPin, HIGH);//red
   digitalWrite(slightPin, HIGH);//red
if(padx.isPressed());
if(pade.isReleased());
if(padp.isReleased());
   digitalWrite(gatePin, HIGH);//open gate
   digitalWrite(nlightPin, HIGH);//red
   digitalWrite(slightPin, LOW);//green
if(padx.isReleased());
if(pade.isReleased());
if(padp.isReleased());
   digitalWrite(gatePin, LOW);//close gate
   digitalWrite(nlightPin, LOW);//geen
   digitalWrite(slightPin, LOW);//green   


if(pade.isPressed());
if(padx.isPressed());
if(padp.isReleased());
   digitalWrite(nlightPin, HIGH);//red
   digitalWrite(slightPin, HIGH);//red
if(pade.isPressed());
if(padk.isPressed());
if(padp.isReleased());
   digitalWrite(gatePin, HIGH);//open gate
   digitalWrite(slightPin, HIGH);//red
   digitalWrite(nlightPin, LOW);//green
//if(padx.isReleased());
if(padp.isReleased());
//if(padp.isReleased());
   digitalWrite(gatePin, LOW);//close gate
   digitalWrite(nlightPin, LOW);//geen
   digitalWrite(slightPin, LOW);//green   
}   
if(padx.isReleased());
    Serial.println("exit clear");
if(pade.isPressed());
   Serial.println("enter");
   digitalWrite(gatepin, HIGH);
if(pade.isReleased());
    Serial.println("enter clear");
if(padp.isPressed());
   Serial.println("pres");
if(padp.isReleased());
    Serial.println("presence clear");
if(padk.isPressed());
   Serial.println("keypad");
if(padk.isReleased());
    Serial.println("keypad time-out");  

 Arduino: 1.8.19 (Windows 10), Board: "Arduino Uno"
`````````````````````````````````````````````````

















the tonne of error mesages::::::::


C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino: In function 'void loop()':

multibutton:37:17: error: 'nlightPin' was not declared in this scope

    digitalWrite(nlightPin, HIGH);//red

                 ^~~~~~~~~

C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino:37:17: note: suggested alternative: 'nlightpin'

    digitalWrite(nlightPin, HIGH);//red

                 ^~~~~~~~~

                 nlightpin

multibutton:38:17: error: 'slightPin' was not declared in this scope

    digitalWrite(slightPin, HIGH);//red

                 ^~~~~~~~~

C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino:38:17: note: suggested alternative: 'slightpin'

    digitalWrite(slightPin, HIGH);//red

                 ^~~~~~~~~

                 slightpin

multibutton:42:17: error: 'gatePin' was not declared in this scope

    digitalWrite(gatePin, HIGH);//open gate

                 ^~~~~~~

C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino:42:17: note: suggested alternative: 'gatepin'

    digitalWrite(gatePin, HIGH);//open gate

                 ^~~~~~~

                 gatepin

C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino: At global scope:

multibutton:71:1: error: expected unqualified-id before 'if'

 if(padx.isReleased());

 ^~

multibutton:72:5: error: 'Serial' does not name a type

     Serial.println("exit clear");

     ^~~~~~

multibutton:73:1: error: expected unqualified-id before 'if'

 if(pade.isPressed());

 ^~

multibutton:74:4: error: 'Serial' does not name a type

    Serial.println("enter");

    ^~~~~~

multibutton:75:16: error: expected constructor, destructor, or type conversion before '(' token

    digitalWrite(gatepin, HIGH);

                ^

multibutton:76:1: error: expected unqualified-id before 'if'

 if(pade.isReleased());

 ^~

multibutton:77:5: error: 'Serial' does not name a type

     Serial.println("enter clear");

     ^~~~~~

multibutton:78:1: error: expected unqualified-id before 'if'

 if(padp.isPressed());

 ^~

multibutton:79:4: error: 'Serial' does not name a type

    Serial.println("pres");

    ^~~~~~

multibutton:80:1: error: expected unqualified-id before 'if'

 if(padp.isReleased());

 ^~

multibutton:81:5: error: 'Serial' does not name a type

     Serial.println("presence clear");

     ^~~~~~

multibutton:82:1: error: expected unqualified-id before 'if'

 if(padk.isPressed());

 ^~

multibutton:83:4: error: 'Serial' does not name a type

    Serial.println("keypad");

    ^~~~~~

multibutton:84:1: error: expected unqualified-id before 'if'

 if(padk.isReleased());

 ^~

multibutton:85:5: error: 'Serial' does not name a type

     Serial.println("keypad time-out");

     ^~~~~~

multibutton:90:1: error: expected declaration before '}' token

 }

 ^

exit status 1

'nlightPin' was not declared in this scope



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Than you for any assistance you can provide.

You should hear my neighbors. But seriously, please copy and paste the entire error message verbatim, so we can see the details.

LOL that's funny Thank you for getting back to me so quickly Here is the error message

Arduino: 1.8.19 (Windows 10), Board: "Arduino Uno"

C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino: In function 'void loop()':

multibutton:37:1: error: 'pad' was not declared in this scope

pad digitalWrite(nlightPin, HIGH);//red

^~~

C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino:37:1: note: suggested alternative: 'padk'

pad digitalWrite(nlightPin, HIGH);//red

^~~

padk

multibutton:38:17: error: 'slightPin' was not declared in this scope

digitalWrite(slightPin, HIGH);//red

             ^~~~~~~~~

C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino:38:17: note: suggested alternative: 'slightpin'

digitalWrite(slightPin, HIGH);//red

             ^~~~~~~~~

             slightpin

multibutton:42:17: error: 'gatePin' was not declared in this scope

digitalWrite(gatePin, HIGH);//open gate

             ^~~~~~~

C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino:42:17: note: suggested alternative: 'gatepin'

digitalWrite(gatePin, HIGH);//open gate

             ^~~~~~~

             gatepin

multibutton:43:17: error: 'nlightPin' was not declared in this scope

digitalWrite(nlightPin, HIGH);//red

             ^~~~~~~~~

C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino:43:17: note: suggested alternative: 'nlightpin'

digitalWrite(nlightPin, HIGH);//red

             ^~~~~~~~~

             nlightpin

C:\Users\fal\Documents\Arduino\multibutton\multibutton.ino: At global scope:

multibutton:71:1: error: expected unqualified-id before 'if'

if(padx.isReleased());

^~

multibutton:72:5: error: 'Serial' does not name a type

 Serial.println("exit clear");

 ^~~~~~

multibutton:73:1: error: expected unqualified-id before 'if'

if(pade.isPressed());

^~

multibutton:74:4: error: 'Serial' does not name a type

Serial.println("enter");

^~~~~~

multibutton:75:16: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite(gatepin, HIGH);

            ^

multibutton:76:1: error: expected unqualified-id before 'if'

if(pade.isReleased());

^~

multibutton:77:5: error: 'Serial' does not name a type

 Serial.println("enter clear");

 ^~~~~~

multibutton:78:1: error: expected unqualified-id before 'if'

if(padp.isPressed());

^~

multibutton:79:4: error: 'Serial' does not name a type

Serial.println("pres");

^~~~~~

multibutton:80:1: error: expected unqualified-id before 'if'

if(padp.isReleased());

^~

multibutton:81:5: error: 'Serial' does not name a type

 Serial.println("presence clear");

 ^~~~~~

multibutton:82:1: error: expected unqualified-id before 'if'

if(padk.isPressed());

^~

multibutton:83:4: error: 'Serial' does not name a type

Serial.println("keypad");

^~~~~~

multibutton:84:1: error: expected unqualified-id before 'if'

if(padk.isReleased());

^~

multibutton:85:5: error: 'Serial' does not name a type

 Serial.println("keypad time-out");

 ^~~~~~

multibutton:90:1: error: expected declaration before '}' token

}

^

exit status 1

'pad' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

The following piece of code has multiple issues.

  • The if does not do anything because of the semicolon. This seems to be the case for every if in your sketch.
  • The word pad seems out of place in the second line.
  • slightPin is not defined, slightpin (without the capital P) is. This is also a recurring problem.

From the indentation, I guess you want to do something along these lines:

if (padp.isReleased()) {
  digitalWrite(nlightpin, HIGH);  //red
  digitalWrite(slightpin, HIGH);  //red
}

A lot of the other compilation errors have a similar cause.

Further on there is an other issue.

The last line in this snippet (and the lines following it) are not inside of a function. You probably want to move them up (before the closing brace of loop).

Good Morning. I would like to thank you so very much, everything fell right into place and it works as it was intended. A capital and a semicolon out of place, To think of how many hours I pondered over this.
Is there anything I can offer you for your assistance?
I am off to work with my Arduino in hand ready to deploy at our gate and I believe my boss will be pleased.
A thousand thank yous and all the best to you and yours Regards Falco Mueller... LOL not so totalmadness.

Just mark the most helpful post as the solution, that will be thanks enough (and it prevents other people spending time on a solved issue).

Isn't it unsafe to open or close the gate when a vehicle is in the middle of the gate?!? I would think that a "presence" signal should STOP the gate from moving.

Good morning John. the safety of this gate is a current sensing circuit in the motor control, stopping the gate from moving.
If a trailer with a more extended hitch or higher profile comes in or out the gate may start to move and stop partially in the closed position trapping the gate arm between truck and trailer so the presence ensures that the gate remains in the fully open position until the respective pads are clear. so when exiting all three pads maintain a fully open gate, on entering only the presence pad maintains an open gate otherwise there could be a tagalong. entry is the key and the enter and presence keep the gate open as soon as the enter pad is clear the enter pad is ignored and only the presence keeps the gate open and as soon as presence is clear the gate closes if the exit pad was in play the gate would remain open for too long thus allowing a tagalong to sneak in but thank you for your input. I see I still have a bit of work to do on the coding but at least I'm not stalled and frustrated and gained some insight from you. do you mind working on this with me a bit further on this for it seems that the if statements are still ignoring my inputs. but I must go the work and perform all the other duties a campground demands.

Hello again your information whent quite a way in compleating this task.BUT, I could use a bit more insight.
What i would like to do is. Example:
If pade is high and padx is high and padp is low, then do as instructed. otherwise move to the next instruction.
i tried your creative use of the { and } regarding the if statement and digitalwrite is beginning to work for me but it seems to skip over compares
This is my code so far:::

#include <ezButton.h>

ezButton padE (3);
ezButton padP (4);
ezButton padX (5);
ezButton padK (6);
const int gatePin = 8;
const int slightPin = 9;
const int nlightPin = 11;

void setup() {
Serial.begin (9600);
padE.setDebounceTime(40);
padP.setDebounceTime(40);
padX.setDebounceTime(40);
padK.setDebounceTime(40);
  pinMode(gatePin,OUTPUT);
  pinMode(slightPin,OUTPUT);
  pinMode(nlightPin,OUTPUT);
 digitalWrite(nlightPin,HIGH);
 digitalWrite(slightPin,HIGH);
 digitalWrite(gatePin,HIGH);
}

void loop() {


padE.loop();
padP.loop();
padX.loop();
padK.loop();

  This is kind of what i would like to do but Arduino is not happy with that
 // (if(padX.isPressed()) and padE.isPressed())and if(padP.isReleased()){

 
 digitalWrite(nlightPin, LOW);
 digitalWrite(slightPin, HIGH);
 digitalWrite(gatePin, LOW);
}
if(padX.isPressed())
if(padE.isReleased())
if(padP.isReleased()){
 digitalWrite(gatePin, LOW);
 digitalWrite(nlightPin, HIGH);
 digitalWrite(slightPin, LOW);
}
if(padX.isReleased())
if(padE.isReleased())
if(padP.isReleased()){
  digitalWrite(gatePin, LOW);
  digitalWrite(nlightPin, LOW);
  digitalWrite(slightPin, LOW);   
}

if(padE.isPressed())
if(padX.isPressed())
if(padP.isReleased()){
   digitalWrite(nlightPin, HIGH);
   digitalWrite(slightPin, HIGH);
}
  
if(padE.isPressed())
if(padK.isPressed())
if(padP.isReleased()){
  digitalWrite(gatePin, HIGH);
  digitalWrite(slightPin, HIGH);
  digitalWrite(nlightPin, LOW);
}
if(padX.isReleased())
if(padP.isReleased())
if(padE.isReleased()){
  digitalWrite(gatePin, LOW);
  digitalWrite(nlightPin, LOW);
  digitalWrite(slightPin, LOW);
}
if(padX.isReleased())                              
if(padE.isReleased())
if(padP.isReleased()){
 digitalWrite(nlightPin, HIGH);
 digitalWrite(slightPin, HIGH);
 digitalWrite(gatePin, HIGH);
}   
if(padX.isPressed()){Serial.println("exit");}  
if(padX.isReleased()){Serial.println("exit clear");}
if(padE.isPressed()){ Serial.println("enter");}

if(padE.isReleased()){Serial.println("enter clear");}
if(padP.isPressed()){ Serial.println("presence");}
if(padP.isReleased()){ Serial.println("presence clear");}
if(padK.isPressed()){ Serial.println("keypad");}
if(padK.isReleased()){ Serial.println("keypad time-out");}   

}

Have a good night and i thank you again for your assistance.

What is your intention?

As it is written now, the code between {} is only executed when all three if statements are true. It does the same as the following.

if (padX.isPressed() and padE.isReleased() and padP.isReleased()) {
 digitalWrite(gatePin, LOW);
 digitalWrite(nlightPin, HIGH);
 digitalWrite(slightPin, LOW);
}

If you only want to act on padP.isReleased(), then you can simply remove the first two lines.

Good morning .
That is exactly what I need to do, but for some reason I am not getting the output to the gate and n and s lights for some reason, I was thinking that for some reason it was missing or passing by some of the if statements. For instance. When I have a vehical on the exit pad and all other pads clear the gate should open and s light should be green and n light should be red. :thinking::thinking: that's not happening. Then when the pads are clear it should revert to both lights green and gate closed. If it's not the if statements causing this not to happen then am I doing something wrong? With the digital write statements. It seems such an easy task but somthing is still a miss. The serial output is bang on so all inputs are responding. Could it be because I am employing the ezbutton library and this is not interacting properly with digital write?

No. Both of those work perfectly. If they don't "interact properly" it's just another way of expressing that your code is buggy.

This kind of speculation doesn't get you any closer to a solution. You need to do some standard troubleshooting using debug statements and divide and conquer methodology.

You are asking about code that we can't see. Please re-post your sketch if it has been modified since you last posted it.

Thank you for your responce, i have tried multiple aproches to this. this is where im at now



#include <ezButton.h>

ezButton padE (3);
ezButton padP (4);
ezButton padX (5);
ezButton padK (6);
const int gatePin = 8;
const int slightPin = 9;
const int nlightPin = 11;

void setup() {
Serial.begin (9600);
padE.setDebounceTime(40);
padP.setDebounceTime(40);
padX.setDebounceTime(40);
padK.setDebounceTime(40);
  pinMode(gatePin,OUTPUT);
  pinMode(slightPin,OUTPUT);
  pinMode(nlightPin,OUTPUT);
 digitalWrite(nlightPin,HIGH);
 digitalWrite(slightPin,HIGH);
 digitalWrite(gatePin,HIGH);
}

void loop() {


padE.loop();
padP.loop();
padX.loop();
padK.loop();

 
  if(padX.isPressed()) 
  if (padE.isPressed())
  if(padP.isReleased()){
 digitalWrite(nlightPin, LOW);
 digitalWrite(slightPin, HIGH);
 digitalWrite(gatePin, LOW);
}
if(padX.isPressed())
if(padE.isReleased())
if(padP.isReleased()){
 digitalWrite(gatePin, LOW);
 digitalWrite(nlightPin, HIGH);
 digitalWrite(slightPin, LOW);
}
if(padX.isReleased())
if(padE.isReleased())
if(padP.isReleased()){
  digitalWrite(gatePin, LOW);
  digitalWrite(nlightPin, LOW);
  digitalWrite(slightPin, LOW);   
}

if(padE.isPressed())
if(padX.isPressed())
if(padP.isReleased()){
   digitalWrite(nlightPin, HIGH);
   digitalWrite(slightPin, HIGH);
}
  
if(padE.isPressed())
if(padK.isPressed())
if(padP.isReleased()){
  digitalWrite(gatePin, HIGH);
  digitalWrite(slightPin, HIGH);
  digitalWrite(nlightPin, LOW);
}
if(padX.isReleased())
if(padP.isReleased())
if(padE.isReleased()){
// digitalWrite(gatePin, LOW);
// digitalWrite(nlightPin, LOW);
// digitalWrite(slightPin, LOW);
}
if(padX.isReleased())                              
if(padE.isReleased())
if(padP.isReleased()){
 digitalWrite(nlightPin, HIGH);
 digitalWrite(slightPin, HIGH);
 digitalWrite(gatePin, LOW);
}
if(padX.isPressed()){Serial.println("exit");}  
if(padX.isReleased()){Serial.println("exit clear");}
if(padE.isPressed()){ Serial.println("enter");}

if(padE.isReleased()){Serial.println("enter clear");}
if(padP.isPressed()){ Serial.println("presence");}
if(padP.isReleased()){ Serial.println("presence clear");}
if(padK.isPressed()){ Serial.println("keypad");}
if(padK.isReleased()){ Serial.println("keypad time-out");}   

}
````````````````````

You have some apparently contradictory code. Your first set of ifs does the same check as the fourth, but they take different actions.

I would comment everything out except the first set and test. Then add them in a set at a time and test everything again. Add some serial prints so you know which sets of ifs were satisfied.

yes thank you i have been following that course of action.

...and the result is?....

not too good. I think that I was trying to make it too simple because the gate and traffic lighting just didn't respond when they were supposed to I need to have the program follow the vehicles through in both directions, I have been attempting to set up a too loop inside a void loop void loop ascertain the direction of travel and loop 1 the exit and loop 2 the ingress. driving me nuts at the moment so doing lots of reading and trial and error scenarios.
Here is the code I have been trying I have been messing with it so lots of mistakes but mabey you have a look and let me know if I am on the right track or not.

#define func1()
#define func2()
#include <Arduino.h>
#include <ezButton.h>
//#include <ATtinySerialOut.h>
ezButton padE (3, INPUT_PULLUP);
ezButton padP (4, INPUT_PULLUP);
ezButton padX (5, INPUT_PULLUP);
ezButton padK (6, INPUT_PULLUP);
const int gatePin = 8;
const int slightPin = 9;
const int nlightPin = 11;

void setup()
{
Serial.begin (9600);
padE.setDebounceTime(4);
padP.setDebounceTime(4);
padX.setDebounceTime(4);
padK.setDebounceTime(4);
pinMode(gatePin,OUTPUT);
pinMode(slightPin,OUTPUT);
pinMode(nlightPin,OUTPUT);
digitalWrite(gatePin, HIGH);//CLOSED
digitalWrite(nlightPin, HIGH);//GREEN
digitalWrite(slightPin, HIGH);//GREEN
}
void loop(){

//STANDBY
{
padE.loop();
padP.loop();
padX.loop();
padK.loop();

if(padX.isPressed()){Serial.println("exit");}
if(padX.isReleased()){Serial.println("exit clear");}
if(padE.isPressed()){ Serial.println("enter");}
if(padE.isReleased()){Serial.println("enter clear");}
if(padP.isPressed()){ Serial.println("presence");}
if(padP.isReleased()){ Serial.println("presence clear");}
if(padK.isPressed()){ Serial.println("keypad");}
if(padK.isReleased()){ Serial.println("keypad time-out");}
}

{
if(padX.isPressed())

void func1()

void func2

padE.isReleased())
if(padP.isPressed())
if(padK.isReleased())
digitalWrite(gatePin, LOW);//open
digitalWrite(nlightPin, LOW);//red
digitalWrite(slightPin, HIGH);//GREEN
}
if(padX.isReleased()){
if(padE.isPressed())
if(padP.isPressed())
if(padK.isReleased())
digitalWrite(gatePin, LOW);//OPEN
digitalWrite(nlightPin, LOW);//RED
digitalWrite(slightPin, LOW);//RED
}

if(padX.isReleased()){
if(padE.isPressed())
if(padP.isReleased())
if(padK.isReleased())
digitalWrite(gatePin, HIGH);//CLOSED
digitalWrite(nlightPin, LOW);//RED
digitalWrite(slightPin, LOW);//RED
}

if(padX.isReleased()){
if(padE.isReleased())
if(padP.isReleased())
if(padK.isReleased())
digitalWrite(gatePin, HIGH);//CLOSED
digitalWrite(nlightPin, HIGH);//GREEN
digitalWrite(slightPin, HIGH);//GREEN
}

if(padX.isReleased()){
if(padE.isPressed())
if(padP.isReleased())
if(padK.isReleased())
digitalWrite(gatePin, HIGH);//CLOSE
digitalWrite(nlightPin, HIGH);//GREEN
digitalWrite(slightPin, HIGH);//GREEN
}

if(padX.isReleased()){
if(padE.isReleased())
if(padP.isReleased())
if(padK.isReleased())
digitalWrite(gatePin, HIGH);//CLOSED
digitalWrite(nlightPin, HIGH);//GREEN
digitalWrite(slightPin, HIGH);//GREEN
}

if(padX.isReleased()){
if(padE.isReleased())
if(padP.isReleased())
if(padK.isReleased())
digitalWrite(gatePin, HIGH);//CLOSED
digitalWrite(nlightPin, HIGH);//GREEN
digitalWrite(slightPin, HIGH);//GREEN
}
}
void func2()
{
{Serial.println("FUNCTION 2");}
delay(40)
}
{
if(padX.isReleased())
if(padE.isPressed())
if(padP.isPressed())
if(padK.isReleased())
digitalWrite(gatePin, LOW);//open
digitalWrite(nlightPin, HIGH);//GREEN
digitalWrite(slightPin, LOW);//RED
}

if(padX.isPressed()){
if(padE.isReleased())
if(padP.isPressed())
if(padK.isReleased())
digitalWrite(gatePin, LOW);//OPEN
digitalWrite(nlightPin, LOW);//RED
digitalWrite(slightPin, LOW);//RED
}

if(padX.isPressed()){
if(padE.isReleased())
if(padP.isPressed())
if(padK.isReleased())
digitalWrite(gatePin, LOW);//OPEN
digitalWrite(nlightPin, LOW);//RED
digitalWrite(slightPin, LOW);//RED
}

if(padX.isPressed()){
if(padE.isReleased())
if(padP.isReleased())
if(padK.isReleased())
digitalWrite(gatePin, HIGH);//CLOSED
digitalWrite(nlightPin, LOW);//RED
digitalWrite(slightPin, LOW);//RED
}

if(padX.isReleased()){
if(padE.isReleased())
if(padP.isReleased())
if(padK.isReleased())
digitalWrite(gatePin, HIGH);//CLOSE
digitalWrite(nlightPin, HIGH);//GREEN
digitalWrite(slightPin, HIGH);//GREEN
}

}

Code tags... also, does it compile without errors?

Hey, I thought this was supposed to be easy to some degree. I have now put in almost every waking moment other than work itself into this most likely easy project and do you know what I gleaned from this so far? Well, maybe I shouldn't code. I'm caught in a vicious circle my brain is MUSH and I think it is total madness, I did have compilation on many occasions but it didn't do as I needed, all I ask from it is to turn a couple of lights on or off as a vehicle traverses the gate in or out and one stuped command to open or close the gate. it's beyond me I think, I was seriously ready to pack this computer up and toss it into my pond for a swim. I counted to 100 and reevaluated, I realized it's not the computer's fault but my own so I still have it on my desk. anyway, I'm done reading and running around in circles. would you take another look at it for me please, I did do a different approach to it, and maybe it's not the right one either.


```
#define func1()
#define func2() 

#include <ezButton.h>

ezButton padE (3, INPUT_PULLUP);
ezButton padP (4, INPUT_PULLUP);
ezButton padX (5, INPUT_PULLUP);
ezButton padK (6, INPUT_PULLUP);
const int gatePin = 8;
const int slightPin = 9;
const int nlightPin = 11;

void setup() 
{
Serial.begin (9600);
padE.setDebounceTime(4);
padP.setDebounceTime(4);
padX.setDebounceTime(4);
padK.setDebounceTime(4);
  pinMode(gatePin,OUTPUT);
  pinMode(slightPin,OUTPUT);
  pinMode(nlightPin,OUTPUT);
 digitalWrite(gatePin, HIGH);//CLOSED
 digitalWrite(nlightPin, HIGH);//GREEN
 digitalWrite(slightPin, HIGH);//GREEN
}
  void loop(){

  //STANDBY
 { 
padE.loop();
padP.loop();
padX.loop();
padK.loop();


  if(padX.isPressed()){Serial.println("exit");}
   //if(padX.isReleased()){Serial.println("exit clear");}
  if(padE.isPressed()){ Serial.println("enter");}
  //if(padE.isReleased()){Serial.println("enter clear");}
  //if(padP.isPressed()){ Serial.println("presence");}
  //if(padP.isReleased()){ Serial.println("presence clear");}
  if(padK.isPressed()){ Serial.println("keypad");} 
  //if(padK.isReleased()){ Serial.println("keypad time-out");
  
  
 

 if(padX.isPressed()) 
  func1()  
 
 if(padE.isPressed())
  func2()
  digitalWrite(nlightPin, LOW);
  digitalWrite(slightPin, LOW);
}
func1()

   if(padE.isReleased()){
   if(padX.isPressed())                            
   if(padP.isPressed())
   if(padK.isReleased())  
 digitalWrite(gatePin, LOW);//open
 digitalWrite(nlightPin, LOW);//red
 digitalWrite(slightPin, HIGH);//GREEN
}

if(padX.isReleased()){
if(padE.isPressed())
if(padP.isPressed())
if(padK.isReleased())
 digitalWrite(gatePin, LOW);//OPEN
 digitalWrite(nlightPin, LOW);//RED
 digitalWrite(slightPin, LOW);//RED
}

if(padX.isReleased()){
if(padE.isPressed())
if(padP.isReleased())
if(padK.isReleased())
 digitalWrite(gatePin, HIGH);//CLOSED
 digitalWrite(nlightPin, LOW);//RED
 digitalWrite(slightPin, LOW);//RED
}
if(padX.isReleased()){
  if(padE.isReleased())
  if(padP.isReleased())
  if(padK.isReleased())  
 digitalWrite(gatePin, HIGH);//CLOSED
 digitalWrite(nlightPin, HIGH);//GREEN
 digitalWrite(slightPin, HIGH);//GREEN
}

if(padX.isReleased()){
if(padE.isPressed())
if(padP.isReleased())
if(padK.isReleased())
 digitalWrite(gatePin, HIGH);//CLOSE
 digitalWrite(nlightPin, HIGH);//GREEN
 digitalWrite(slightPin, HIGH);//GREEN
}
 
  if(padX.isReleased()){
  if(padE.isReleased())
  if(padP.isReleased())
  if(padK.isReleased())
  digitalWrite(gatePin, HIGH);//CLOSED
  digitalWrite(nlightPin, HIGH);//GREEN
  digitalWrite(slightPin, HIGH);//GREEN
  }
  
  if(padX.isReleased()){
  if(padE.isReleased())
  if(padP.isReleased())
  if(padK.isReleased())
 digitalWrite(gatePin, HIGH);//CLOSED
 digitalWrite(nlightPin, HIGH);//GREEN
 digitalWrite(slightPin, HIGH);//GREEN
} 
  }
   func2()
  
  

    

  if(padX.isReleased()){
  if(padE.isPressed())
  if(padP.isPressed())
  if(padK.isReleased())  
 digitalWrite(gatePin, LOW);//open
 digitalWrite(nlightPin, HIGH);//GREEN
 digitalWrite(slightPin, LOW);//RED
}

if(padX.isPressed()){
if(padE.isReleased())
if(padP.isPressed())
if(padK.isReleased())
 digitalWrite(gatePin, LOW);//OPEN
 digitalWrite(nlightPin, LOW);//RED
 digitalWrite(slightPin, LOW);//RED
 }

if(padX.isPressed()){
if(padE.isReleased())
if(padP.isPressed())
if(padK.isReleased())
 digitalWrite(gatePin, LOW);//OPEN
 digitalWrite(nlightPin, LOW);//RED
 digitalWrite(slightPin, LOW);//RED
 }

  if(padX.isPressed()){
  if(padE.isReleased())
  if(padP.isReleased())
  if(padK.isReleased())  
 digitalWrite(gatePin, HIGH);//CLOSED
 digitalWrite(nlightPin, LOW);//RED
 digitalWrite(slightPin, LOW);//RED
 }

  if(padX.isReleased()){
if(padE.isReleased())
if(padP.isReleased())
if(padK.isReleased())
 digitalWrite(gatePin, HIGH);//CLOSE
 digitalWrite(nlightPin, HIGH);//GREEN
 digitalWrite(slightPin, HIGH);//Green
```
  
  }
  }`````````````````````````````Preformatted text
well I'm going to go bang my head agansed the wall for a while.

That is one of your uncommon if statements formatted so you can see what the compiler sees.

Which is the same as has been pointed out as

if(padX.isReleased()) {

    if (padE.isPressed() and padP.isReleased() and padK.isReleased()) {
        digitalWrite(gatePin, HIGH); //CLOSED
    }

    digitalWrite(nlightPin, LOW); //RED
    digitalWrite(slightPin, LOW); //RED
}

I srsly doubt that's what you think it amounts to.

Also, I'll go read about ezButton, but it seems unusual to be using isPressed and isReleased the way you do.

Please describe what you are trying to say with, for example, just the if statement I quoted above.

a7