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;
}
}
}
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
my code was basically from http://tronixstuff.com/tutorials > chapter 42. I have changed and added sections so that I can
1. Get a PIN for authority.
2. Get the message from the keypad.
3. Send the message wirelessly to another NRF24 / Arduino for display on a large 7 segment display.
4. Reset and wait for the next PIN etc.
I have all the sections working individually but cannot seem to go to the right section based on the results of the previous section.
In basic I would jump to a subroutine and go back to the main code for the next operation. In this sketch (LCDKeypad) I keep ending up in the wrong place in the code.
This is probably just my lack of understanding of C++.I have looked over many samples but cannot find code close enough to help me.could you please look over the sketch
and provide guidance. your previous help is very much appreciated.
//keypad/LCD combo // http://tronixstuff.com/tutorials > chapter 42 #include <Wire.h> #include <Keypad.h> #include<LiquidCrystal.h> //Char Kid(); // need string here 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', '#'} }; //define Arduino pins & rows byte rowPins[ROWS] = {2, 3, 4, 5}; byte colPins[COLS] = {6, 7, 8}; //KeyMap Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); //////// AUTHORIZATION CODE /////// // Change Here if new one is desired // char PIN[4] = {'4', '3', '1','6'}; // our secret (!) number char attempt[4] = {'0', '0', '0','0'}; // used for comparison int z = 0; //************* SETUP ******************************* void setup() { Serial.begin(9600); lcd.begin(16, 2); delay(100); lcd.clear(); lcd.print(" Enter PIN..."); lcd.setCursor(6, 1); lcd.cursor(); lcd.blink(); } //*********** PIN OK ********************* void correctPIN() // do this if correct PIN entered { int(j); for ( j = 0; j < 4 ; j++ ) lcd.clear(); lcd.print(" Enter Kid #"); Serial.print("I got here"); /////////test/////// /* char key = keypad.getKey(); //delay(100); if (key != NO_KEY) { lcd.print(key); attempt[j] = key; j++; Serial.print("I got here"); /////////test/////// char(Kid) = key; lcd.print(Kid); } switch (key) { case '*': z = 0; break; case '#': z = 0; //lcd.clear(); //lcd.print(" Enter PIN..."); lcd.setCursor(6, 1); } */ } //************ incorrect pin entered ******************* void incorrectPIN() // do this if incorrect PIN entered { lcd.clear(); delay(100); lcd.print(" * Try Again *"); delay(2000); lcd.clear(); lcd.print(" Enter PIN..."); lcd.setCursor(6, 1); } //************** CHECK PIN ******************************** void checkPIN() { int correct = 0; int i; for ( i = 0; i < 4 ; i++ ) { Serial.print(correct); if (attempt[i] == PIN[i]) { correct++; // Serial.print(PIN); //Serial.print(i); // Serial.print(i); if (correct == 3); correctPIN(); } else incorrectPIN(); } for (int zz = 0; zz < 3; zz++) { attempt[zz] = '0'; } } //************** READ KEPAD ******************************** void readpad() { char key = keypad.getKey(); delay(100); if (key != NO_KEY) { lcd.print(key); attempt[z] = key; z++; } switch (key) { case '*': z = 0; break; case '#': z = 0; // delay(100); // for extra debounce // lcd.clear(); checkPIN(); break; } } //*************** LOOP ********** void loop() { readpad();