problems with lcd display working together with 4*3 keypad

Hii comm,

I am 17 years old and I am making a school project for my exam. And using this posting thing for the first time. Right now I am trying to make a little book search machine. When you press a button on the keypad it will show on the lcd display but I am stuck at this moment.

I am trying to get the numbers, I pressed on the keypad, in the second row of my lcd screen. But right now the previous number I pressed will be replaced for the next number that is pressed.

Second problem, I want to send the numbers I pressed to a Python script. Is that possible?

Can someone please help me?

Here is my code:

#include <LiquidCrystal.h>
#include <Keypad.h>

const byte numRows= 4;
const byte numCols= 3;

LiquidCrystal lcd(8, 9, 7, 6, 5, 4);

char keymap[numRows][numCols]=
{
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};

byte rowPins[numRows]= {13, 12, 11, 10};
byte colPins[numCols]= {3, 2, A1};

Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

char key,action;
int count=0;

void setup(){
lcd.begin(16, 2);
lcd.print("BOEKNUMMER:");
Serial.begin(9600);

}

void loop() {
char key = myKeypad.getKey();
if (key != NO_KEY)
{
lcd.setCursor(0, 2);
lcd.print(key);
Serial.print(key);
count++;
}
}

Look again at the lcd.setCursor(0, 2); function documentation and see how to set the cursor to the second line.

Paul

Paul_KD7HB:
Look again at the lcd.setCursor(0, 2); function documentation and see how to set the cursor to the second line.

Paul

Hii Paul,

Thanks for the tip, but the first position of the numbers is good. But when I press a second number it will overwrite the first number.

(post deleted by author)

If you want to write on row 2 you should write lcd.setCursor(1,0) and not lcd.setCursor(0,2)

The setCursor() function is lcd.setCursor(col, row);
So the to print to the first character of the second row is

lcd.setCursor(0, 1);

to0n7:
If you want to write on row 2 you should write lcd.setCursor(1,0) and not lcd.setCursor(0,2)

yes but it is still overwriting the previous number and not making a row

(post deleted by author)

to0n7:
If I understand well what you want. You create a variable that increase each loop to choose where write

yes that's correct but someone else already helped me! It is now working... I only have another problem right now because I am trying to get the Serial output of my anduino into Python. I only need a "enter" command in my script but I don't no how...

(post deleted by author)

The escape character for line feed (enter in Python?) is '\n' in C++ (Arduino). Or Serial.println() sends a line feed and carriage return.

Thanks you so much my project is now working really smooth. Thanks all!!!