Hi
sry
have marked it with ****
I dont have any idea how to do it
/* Keypadtest.pde
*
* Demonstrate the simplest use of the keypad library.
*
* The first step is to connect your keypad to the
* Arduino using the pin numbers listed below in
* rowPins[] and colPins[]. If you want to use different
* pins then you can change the numbers below to
* match your setup.
*
*/
#include <Keypad.h>
#include <Password.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
char kode[5];
char start[5] = {'1','2','3','4','5'};
char slut[5] = {'0','0','0','0','0'};
int i = 0;
int f = 0;
int t = 0;
char time[5];
char tid[5];
int a = 5;
//Password password = Password( "9999" );
//Password admin = Password( "0000" );
//Password bruger1 = Password( "1111" );
//Password bruger2 = Password( "2222" );
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] = { 10, 9, 8, 14 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 13, 12, 11 };
// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop(){
char key = kpd.getKey();
if(t == 1) //Hvis admin pass er trykket og godkendt
{
******* the time that is entered is counting down, But if you enter the rigth code (00000)
it stops and go to checkPassword() *****
}
if (t == 0) //Starten af programmet - nulstillet.
{
lcd.setCursor(0, 0);
lcd.print("Tast Start kode");
}
else //Hvis Der er tastet admin kode.
{
lcd.setCursor(2, 0);
lcd.print("Tast Kodeord");
}
if(key && t != 2 && f != 3) // Hvis der trykkes på kaypaddet og bomben er "armed"
{
kode[i] = key; //store entry into array
i++;
Serial.println(key); //print keypad character entry to serial port
lcd.setCursor(a + i, 1);
lcd.print(key);
Serial.println(a , i);
if (key=='*')
{
Serial.println("Reset");
i=0; //reset i
a=5;
lcd.clear();
}
if (i == 5) //if 4 presses have been made
{
checkPassword();
{
i=0;
a=5;
lcd.clear();
}
}
}
if ( f == 3 || t == 2 ) // Hvis der forsøges mere end 3 gange eller tiden er gået.
{
Serial.println( "booom");
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("BOOOOOOOOM");
f = 0;
t = 0;
delay (10000);
Serial.println( "igen");
lcd.clear();
}
}
void checkPassword(){
i=0;
if ( t == 0 && kode[0] == start[0] && // tjekker admin kode og staret programmet i "armed"
kode[1] == start[1] &&
kode[2] == start[2] &&
kode[3] == start[3] &&
kode[4] == start[4] )
{
Serial.println("Start");
t = 1;
f = 0;
lcd.clear();
******* press the time.. finish with # *****
lcd.print(" Armed");
delay(2000);
lcd.clear();
}
else if (t == 1 && kode[0] == slut[0] &&
kode[1] == slut[1] &&
kode[2] == slut[2] &&
kode[3] == slut[3] &&
kode[4] == slut[4] )
{
Serial.println("STOP");
t = 0;
f = 0;
lcd.clear();
lcd.print(" Disarmed");
delay(1500);
lcd.clear();
}
else
{
if ( t == 1 ) // Hvis programmet er startet og koden er forkert.
{
Serial.println("Forkert");
f++;
lcd.clear();
lcd.print("Forkert kode");
lcd.setCursor(0,1);
delay(1000);
lcd.clear();
lcd.print("Forsøg Tilbage");
lcd.setCursor(8,1);
lcd.print(f);
delay(1000);
lcd.clear();
}
}
}