Can anyone help me with this. I got a problem for my lcd display
when my lcd disply it shows
Security code:
when I type in my passwords, it still stick on my cursor and display 1 by 1 on the same cursor
how to make the password in 2nd line and run the character from left to right
Thanks in advances
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
lcd.print("Security Code:");
lcd.setCursor(0,1);
lcd.print(eKey);
switch (eKey){
case ' ': guessPassword(); break;
default:
password.append(eKey);
Sure. It prints the prompt every time you press a key. That's not right.
so what should I do, if I didn't set cursor it will clash with my security code.
Really, how could anybody answer that question without seeing your "security code"?
[code author=Delta_G link=msg=2370537 date=1440506936]
// this is the programming can you try run and see. actually I put the set cursor is like it stuck on that cursor when I press a digit it display and then it clear off by replacing another character
#include <Password.h>
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
LiquidCrystal lcd(12,11,5,4,3,2);
Password password = Password( "1402" );
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] = {25, 24, 23, 22}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {28, 27, 26}; //connect to the column pinouts of the keypad
const int buttonPin = 7;
int buttonState = 0;
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define ledPin 13
void setup(){
pinMode(buttonPin, INPUT);
lcd.begin(16, 2);
digitalWrite(ledPin, LOW); // sets the LED on
Serial.begin(9600);
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
keypad.setDebounceTime(250);
}
void loop(){
keypad.getKey();
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
lcd.clear();
}
}
//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
lcd.print("Security Code:");
lcd.setCursor(0,1);
lcd.print(eKey);
switch (eKey){
case ' ': guessPassword(); break;
default:
password.append(eKey);
}
}}
void guessPassword(){
if (password.evaluate()){
digitalWrite(ledPin,HIGH); //activates garaged door relay
delay(500);
digitalWrite(ledPin,LOW); //turns off door relay after .5 sec
lcd.print("VALID PASSWORD "); //
password.reset(); //resets password after correct entry
delay(600);
lcd.print("Welcome");
delay(2000);
lcd.clear();
}
else{
digitalWrite(ledPin,LOW);
lcd.print("INVALID PASSWORD ");
password.reset(); //resets password after INCORRECT entry
delay(600);
lcd.clear();
}
}
Moderator edit: CODE TAGS, DAMMIT!
You have to separate the action of printing a prompt and collecting the input. Two different tasks.
ok problem solve, I forgot I put at loop, no wonder it is not working. instead I put set cursor on the void setup
thanks for helping guys