What am I doing wrong?

I am making a garage door opener and I want to have led light when it is unlocked but I cant seem to get the variable to change

http://pastebin.com/EsZ4Lm2p

Not everyone can access pastebin. You could attach your code, using the Additional Options link below the gray box where you post your topic/reply.

PaulS: Not everyone can access pastebin. You could attach your code, using the Additional Options link below the gray box where you post your topic/reply.

It's not even that much... it's only 80 lines.

It might help if you set the 'pinMode' BEFORE the 'digitalWrite' -

void setup()
{
  Serial.begin(9600);

  pinMode(doorRelay, OUTPUT);
  pinMode(ledPin, OUTPUT);

  digitalWrite(doorRelay, HIGH);
  digitalWrite(ledPin, LOW);

  resetTimer = millis ();
  keypad.addEventListener(keypadEvent); //add an event listener for keypad
}

lloyddean:
It might help if you set the ‘pinMode’ BEFORE the ‘digitalWrite’ -

dosen’t change anything

here is the code

#include <Keypad.h>
#include <Password.h>
 
const unsigned long resetTime = 300000; //set unlock time
unsigned long resetTimer;
boolean lock = true;
 
Password password = Password( "1234" );
 
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 7, 12, 11, 9 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 8, 6, 10 };
 
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
 
#define doorRelay 2
#define ledPin 13
 
void setup()
{
  digitalWrite(doorRelay, HIGH);
  digitalWrite(ledPin, LOW);
  Serial.begin(9600);
  pinMode(doorRelay, OUTPUT);
  pinMode(ledPin, OUTPUT);
  resetTimer = millis ();
  keypad.addEventListener(keypadEvent); //add an event listener for keypad
}
 
void loop(){
  keypad.getKey();
  if (lock == false)
    digitalWrite (ledPin, HIGH);
  else
    digitalWrite (ledPin, LOW);
}
 
void keypadEvent(KeypadEvent eKey){
  switch (keypad.getState()){
    case PRESSED:
      Serial.print(eKey);
      switch (eKey){
        case '#': Serial.println(); checkPassword(); break;
        case '*': Serial.println(); password.reset(); lock = true; break;
        default: password.append(eKey);
      }
  }
}
 
void checkPassword(){
  if (password.evaluate()){
    Serial.println("Success");
    lock = false;
    digitalWrite(doorRelay, LOW);
    delay(500);
    digitalWrite(doorRelay, HIGH);
    if ( (millis () - resetTimer) <= resetTime)
      passreset ();
    else
      Serial.println("Wrong");
      password.reset();
      lock = true;
  }
}
 
void passreset(){
  password.reset();
  lock = true;
}

In this code, you are unlocking the lock and then waiting until it is time to lock it again; by the time you leave this function, the lock is locked again so your code in loop() to switch the LED on and off never sees the lock being unlocked.

Given this code structure, it would make more sense to put the digitalWrite (ledPin, LOW) where you currently set lock=true, and put digitalWrite (ledPin, HIGH) where you currently put lock=false, and get rid of the lock variable and associated code in loop().

  digitalWrite(doorRelay, HIGH);

Since the pins default to INPUT, you’ve just turned the internal pullup resistor on. Probably NOT what you want to do with a relay pin.

  digitalWrite(ledPin, LOW);

And, here you’ve turned the internal pullup resistor off. Again, not what you want to do with a light pin.

  pinMode(doorRelay, OUTPUT);
  pinMode(ledPin, OUTPUT);

You were told to do this FIRST!

  keypad.getKey();

Read the key that was pressed, but throw the value away. How useful is that?

    if ( (millis () - resetTimer) <= resetTime)
      passreset ();

Changing the value of resetTimer some place might be useful.

Integer literal needs to be specified as unsigned long as per below -

const unsigned long resetTime = 300000UL;   //set unlock time