Password project help


#include <liquidcrystal.h>
#include <wire.h>
#include <password.h>
#include <keypad.h>
#include <servo.h>
//#include "rtclib.h"
servo myservo;               
int pos = 90;
//rtc_ds1307 rtc;
password password = password( "1" );
const byte rows = 4;
const byte cols = 4;

char keys[rows][cols] = {
  {
    '1','2','3','a'      }
  ,
  {
    '4','5','6','b'      }
  ,
  {
    '7','8','9','c'      }
  ,
  {
    '*','0','#','d'      }
};

byte rowpins[rows] = {
  46, 47, 48, 49};     
byte colpins[cols] = {
  50, 51, 52, 53};     


keypad keypad = keypad( makekeymap(keys), rowpins, colpins, rows, cols );


liquidcrystal lcd(7, 8, 9, 10, 11, 12);



int speakerpin = 35;
int alarmstatus = 0;
int zone = 0;
int alarmactive = 0;
int pirpin1 = 32;
int pirpin2 = 33;



void setup(){
  serial.begin(9600);
  lcd.begin(20, 4);
  wire.begin();
 // rtc.begin();
 
//  rtc.adjust(datetime(__date__, __time__));
 
  myservo.attach(2); 

  /*displaycodeentryscreen();
  pinmode(redpin, output);
  pinmode(bluepin, output);
  pinmode(redled, output);
  pinmode(greenled, output);
  pinmode(speakerpin, output); 
  pinmode(relay2, output);  //12v blue led lighting
  pinmode(relay3, output);  //camera, 5v external dc supply
  pinmode(relay4, output);  //
 
  pinmode(pirpin1, input);  //bedroom 2
  pinmode(pirpin2, input);  //garage
  pinmode(reedpin1, input); //front door
  pinmode(reedpin2, input); //back door

  digitalwrite(redled, low);
  digitalwrite(greenled, high);
  digitalwrite(speakerpin, low);
 
  //digitalwrite(relay1, low); //
  digitalwrite(relay2, high); // 12v blue led lighting
  digitalwrite(relay3, high); // camera, 5v external dc supply
  digitalwrite(relay4, low); //
*/
  keypad.addeventlistener(keypadevent); //add event listener keypad
  myservo.write(pos);
}

void loop(){
 /* datetime = rtc.now();
  lcd.setcursor(0,1);
  lcd.print(now.month(), dec);
  lcd.print('/');
  //we print day
  lcd.print(now.day(), dec);
  lcd.print('/'); 
  //we print year
  lcd.print(now.year(), dec);
  lcd.print(' ');
  lcd.setcursor(13,1);
  lcd.print(now.hour(), dec);
  lcd.print(':');
  lcd.setcursor(16,1);
  lcd.print(now.minute(), dec);
  //lcd.print(':');
  //lcd.print(now.second(), dec);
  //delay(1000);
*/
  keypad.getkey();
  //serial.println(digitalread(reedpin2));
  //serial.println(digitalread(pirpin));
  //serial.println(digitalread(pirpin2));
  if (alarmactive == 1){
    if (digitalread(pirpin1) == high)
    {
      zone = 0;
      alarmtriggered();
    }
    if (digitalread(pirpin2) == high)
     {
     zone = 1;
     alarmtriggered();
     }
   }
}
void keypadevent(keypadevent ekey){
  switch (keypad.getstate()){
  case pressed:
    if (passwd_pos - 15 >= 5) {
      return ;
    }
    lcd.setcursor((passwd_pos++),0);
    switch (ekey){
    case '#':                 //# validate password
      passwd_pos  = 15;
      checkpassword();
      break;
    case '*':                 //* reset password attempt
      password.reset();
      passwd_pos = 15;
      break;
    default:
      password.append(ekey);
      lcd.print("*");
    }
  }
}

void alarmtriggered(){
  int expected_pos;
  int incr;
  digitalwrite(speakerpin, high);
  password.reset();
  alarmstatus = 1;
  alarmactive = 0;
  lcd.clear();
  lcd.setcursor(0,2);
  lcd.print("  system triggered  ");
  lcd.setcursor(0,4);
  if (zone == 0)
  {
    lcd.print("  motion in hall  ");
    expected_pos = 65;
    delay(1000);
  }
   if(zone == 1){
    expected_pos = 40;
    lcd.print("motion in bedroom  ");
    delay(1000);
  }
   if (expected_pos > pos) {
     incr = 1;
   } else {
     incr = -1;
   }
   
   for (pos = pos; pos != expected_pos; pos += incr) {
    myservo.write(pos);                  // tell servo go position in variable 'pos'
    delay(5);                            // waits 5ms servo reach position
   }
void checkpassword(){                  // check if pin corrected, if not, retry!
  if (password.evaluate())
  { 
    if(alarmactive == 0 && alarmstatus == 0)
    {
      activate();
    }
    else if( alarmactive == 1 || alarmstatus == 1) {
      deactivate();
    }
  }
  else {
    invalidcode();
  }


void invalidcode()
{
  password.reset();
  lcd.clear();
  lcd.setcursor(1,0);
  lcd.print("invalid code! lol!");
  lcd.setcursor(5,2);
  lcd.print("try again!");
  displaycodeentryscreen();
}

void activate()      // activate system if correct pin entered , display message on screen
{
    lcd.setcursor(0,0);
    lcd.print("system active!");
    alarmactive = 1;
    password.reset();
    delay(2000);
  }
  else{
    deactivate(); 
  }
}

void deactivate()
{
  alarmstatus = 0;
  lcd.clear();
  lcd.setcursor(0,0);
  lcd.print(" system deactivated!");
  digitalwrite(speakerpin, low);
  alarmactive = 0;
  password.reset();
  delay(5000);
  displaycodeentryscreen();
}

void displaycodeentryscreen()   
{
  lcd.clear();
  lcd.setcursor(0,0);
  lcd.print("enter pin:");
  lcd.setcursor(0,2);
  lcd.print("home security system");
  lcd.setcursor(0,3);
  lcd.print("istiyaq");
}






plz me out correcting errors passwrd_pos not declared in scope

quote
help me out correcting errors passwrd_pos not declared in scope
i see no instance of "passwrd_pos", nor "password_pos", nor "password.pos" or that.

what actual error message get?

and why did not use code tags?
please read "how use forum" sticky


Arduino Forum > Using Arduino > Programming Questions > Password project help


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor