I am bogged down in this project
I am bogged down in this project
I see no code what so ever here to write to the LCD, sure you have the library included but thats it
you need to create an instance of the LCD library and send the data to it as you read from the keypad
this might help get you started http://tronixstuff.com/2013/12/16/arduino-tutorials-chapter-42-numeric-keypads/
I have just spent the last while on the link you sent. What an excellent site. Thank you.
I will rewrite the sketch and get back to you with the question of sending the 3 digits to the radio.
You are a great resource.
Bill
Good luck, I look forward to hearing how you did
Peter
No problems, I am quite familiar with using the NRF radios and so could help if needed
You just have to ask
Peter
I think this will be fine. I will have to rewrite some of it since I am using the parallel LCD. Also I will have to go to the Mega since I will not have enough digital pins. (No problem)
Thanks again.
Bill
If you use a SPI to parallel or I2C to parallel chip you could stick with the 328. But the mega is more than able too and provides plenty of additional IO for future expansion
Let us know how you get on
Peter
Peter:
I have rebuilt the sketch using your reference (tronixstuff.com). great tutorials there. thanks.
I am using the mega currently.
This is the error I get when compiling
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/main.cpp:15: undefined reference to `loop'C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/main.cpp:15: undefined reference to `loop'
I went to the above error reference copied (below).
USBDevice.attach();
This the current code
//keypad/LCD combo
// http://tronixstuff.com/tutorials > chapter 42
#include <Keypad.h>
#include<LiquidCrystal.h>
char C1,C2,C3,C4 ;
LiquidCrystal lcd(27, 26, 25, 24, 23, 22);
// Create the Keypad
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','*'}
};
byte rowPins[ROWS] = {5,4,3,2}; // keypad rows to Arduino pins
byte colPins[COLS] = {8,7,6}; //keypad columns to Arduino pins
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
char PIN[6]={
'1','2','A','D','5','6'}; // our secret number
char attempt[6]={
'0','0','0','0','0','0'}; // used for comparison
int z=0;
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("PIN Lock ");
delay(1000);
lcd.clear();
lcd.print(" Enter PIN...");
}
void correctPIN() // do this if correct PIN entered
{
lcd.print("* Correct PIN *");
delay(1000);
lcd.clear();
lcd.print(" Enter PIN...");
}
void incorrectPIN() // do this if incorrect PIN entered
{
lcd.print(" * Try again *");
delay(1000);
lcd.clear();
lcd.print(" Enter PIN...");
}
void checkPIN()
{
int correct=0;
int i;
for ( i = 0; i < 6 ; i++ )
{
if (attempt[i]==PIN[i])
{
correct++;
}
}
if (correct==6)
{
correctPIN();
}
else
{
incorrectPIN();
}
for (int zz=0; zz<6; zz++)
{
attempt[zz]='0';
}
}
void readKeypad()
{
char key = keypad.getKey();
if (key != NO_KEY)
{
attempt[z]=key;
z++;
switch(key)
{
case '*':
z=0;
break;
case '#':
z=0;
delay(100); // for extra debounce
lcd.clear();
checkPIN();
break;
}
}
}
Very straight forward problem:
every sketch MUST have two functions specifically "Setup()" which you have, this is used to initialize stuff your using and also "loop()" where you kick off your code. The error your getting is because you dont have the lop() function.
this is the one from the chapter42 of the tronix web site
void loop()
{
char key = keypad.getKey();
if (key != NO_KEY)
{
lcd.print(key);
count++;
if (count==17)
{
lcd.clear();
count=0;
}
}
}
you need a loop() function also to read the keypad, collect your keys and display them onto the lcd, also to call your functions like CheckKey() etc.
That is why you have the error shown
Oh, they MUST have those two, but you can add your own funcions as well
I am so embarrassed. I obviously deleted while I was cleaning it up. What a foolish mistake. I vow to pay better attention in the future. Thanks for being so nice.
Bill
No worries, happens to us all from time to time
I am coming along nicely in the time that I have to give to the project. Learning is hard at my age.
I am thinking about using the 74C922 keyboard decoder. I will give me a Data Available pin and includes de-bounce as well.
This will save me 3 pins and allow me to forgo the Mega.
My question is how hard is it to read and store BCD data.
I cant seem to find any help for inputting BCD to the Arduino. Can you help?
I am coming along nicely in the time that I have to give to the project. Learning is hard at my age.
I am thinking about using the 74C922 keyboard decoder. I will give me a Data Available pin and includes de-bounce as well.
This will save me 3 pins and allow me to forgo the Mega.
My question is how hard is it to read and store BCD data.
I cant seem to find any help for inputting BCD to the Arduino. Can you help?
Bill,
I cannot help you with the 74C922 because, last time I looked, it was somewhat expensive here in the UK. I used the PCF8574 I2C I/O expander with a 4 * 4 matrix keypad. The PCF8574 is considerably cheaper than the 94C922 and to my mind much more flexible and versatile once you have mastered its control. Being I2C it only uses two pins on the Arduino and it has 8 programmable addresses.
The libraries I used are keypad_I2C.h and keypad.h. These libraries provide the value of the key pressed to the Arduino and you can choose what value each key represents, for example you could choose to return the ASCII value of the key, say 8. This value could be printed directly to an LCD or you could subtract ASCII 0 from it to get the numerical value.
I really like my I2C key pad, it works well along with my I2C LCD display on the same two pins! but with different addresses. I have had no issues with key bounce problems and I believe the library takes care of this anyway. There is no BCD manipulation.
hope that helps
Bob
I concur, the I2C 8574 is an easy chip to control and scanning a matrix keyboard has been done several times with it so there should be a few examples available on the web for you