Hi everyone,
I have built all of the hardware, very few components indeed, consisting of the keypad itself, a bit of proto board, a few resistors,LED's and ATTINY85 and a 2n2222a transistor to drive a relay.
These keypads are all different in terms of pinout as it happens, so i had to spend considerable time working out how to wire up the resistor ladder!
My ultimate plan is to design a combination lock that takes in a number of pins "say four" and checks if they were entered correctly, if so, then turn on a green LED and drive a NC relay, if not, then continue displaying a red LED.
Also, I'd like to set up a password learning system, so that if I hold down a key for 10 seconds for example, both LED's will flash once per second, for it to prompt me to enter a new password, then start flashing once every 200mS for me to confirm the password before setting it.
Would anyone be kind enough to give me a few pointers here?
I have added two libraries to my IDE, #include <OnewireKeypad.h> and #include <Password.h>.
Borrowed from:
http://playground.arduino.cc/Code/OneWireKeyPad
http://playground.arduino.cc/Code/Password
Here is my code so far...
#include <Password.h>
Password password = Password( "1234" );
#include <OnewireKeypad.h>
#define Rows 4
#define Cols 3
#define Pin 2//ANALOG Input 1 (pin 7)on ATTINTY85
#define Col_Res 4700
#define Row_Res 1000
char KEYS[]= {
'1','2','3',
'4','5','6',
'7','8','9',
'*','0','#'
};
OnewireKeypad <Print, 12> KeyPad(Serial, KEYS, Rows, Cols, Pin, Col_Res, Row_Res );
int GreenLed = 0;//Unlocked Status LED
int RedLed = 1;//Locked Status LED
int Relay = 3;//Electrical System Disable Relay
void setup(){
pinMode (GreenLed,OUTPUT);//Set all as outputs
pinMode (RedLed,OUTPUT);
pinMode (Relay,OUTPUT);
password.append('1');//add 1 to the guessed password
password.append('2');//add 2 to the guessed password
password.append('3');//add 3 to the guessed password
password.append('4');//add 4 to the guessed password
password.reset(); //reset the guessed password to NULL
password.set("qwerty"); //set target password to qwerty
}
void loop(){
Any help would be greatly appreciated, I'm sure this has been done before, id like to also learn how to program in extra functions once i get this part up and running, including an LCD, however this one with the LED's is cheap to build and is effective, I want to put one in my car to disable the ignition when parked and also one for the door to my house!
Mike