4x3 Keypad with LCD display

hey , guys I have some project which involve in arduino code. I am a beginners for this code. Whenever I stored the value inside, when I pressed the keypad '#', it didn't stored the value inside. what shall I do? I stuck here. someone help.

here is my code :

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

#define Weight_Length 255
LiquidCrystal lcd (A0,A1,A2,A3,A4,A5);

char Data[Weight_Length];
char Weight;
byte data_count = 0;

float circumference;
int Kph;
int CB;

const byte rows =4;
const byte cols =3;
char keys[rows][cols]={
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};

byte rowPins[rows] = {3,4,5,6};
byte colPins[cols] = {7,8,9};

Keypad kpd = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);

void setup() {
lcd.begin(16, 2);
lcd.println("ENTER WEIGHT ");
kpd.addEventListener(keypadEvent);
}

void loop() {
Weight = kpd.getKey();
if (Weight){
Data[data_count] = Weight;
lcd.setCursor(data_count ,1);
lcd.print(Data[data_count]);
data_count++;
}
}
// This can key in unlimited digits
//pass

void keypadEvent(KeypadEvent key){
switch (kpd.getState()){
case PRESSED:
if (key == '#'){
lcd.clear();
break;
}
}
}

sketch_jul19a.ino (966 Bytes)

Hi, and welcome.

Please read the guidelines on how to use the forum (click !).
It will teach you how to post tour code in the proper way, and a lot of other things to consider.

I'm not sure what you mean by 'stored inside'.
Do you mean you do not see the '#' on your LCD ?
Because that is correct, once you type that '#', the LCD's contents are erased.

Instead, go and process your variable called 'data', once you've registered the "#" and erased your display.

No , its not that, when i pressed the key '#'. it cant stored the previous integer that i typed in the void setup.

here is my code :

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

#define Weight_Length 255
LiquidCrystal lcd (A0,A1,A2,A3,A4,A5);

char Data[Weight_Length];
char Weight;
byte data_count = 0;
int a(13);
boolean blink = false;
boolean ledpin_state;

const byte rows =4;
const byte cols =3;
char keys[rows][cols]={
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};

byte rowPins[rows] = {3,4,5,6};
byte colPins[cols] = {7,8,9};

Keypad kpd = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);

void setup() {
lcd.begin(16, 2);
lcd.println("ENTER WEIGHT ");
ledpin_state = digitalRead(a);
kpd.addEventListener(keypadEvent);
}

void loop() {
Weight = kpd.getKey();
if (Weight){
Data[data_count] = Weight;
lcd.setCursor(data_count ,1);
lcd.print(Data[data_count]);
data_count++;
}
}
// This can key in unlimited digits
//pass

void keypadEvent(KeypadEvent key){
switch (kpd.getState()){
case PRESSED:
a= Weight;
if (key == '#'){
lcd.clear();
ledpin_state = digitalRead(a);
digitalWrite(a,!digitalRead(a));
lcd.println("Weight = ");
lcd.setCursor (data_count ,1);
lcd.print(Data[data_count]);

break;

case RELEASED:
if (key == '#'){
digitalWrite(a,ledpin_state);
blink = false;
}
break;
}
}
}

Hi.

I can't help you.
I don't understand what you are trying to communicate.

But far worse: You did not read the link i gave you, and now you've started crossposting.

Goodbye.

So someone deleted your crosspost.

Here's 2 pieces of advice:

  • Take the advice given, and do something with it.[/li][/list]

  • What's this ?int a(13);

MAS3:

  1. What's this ?int a(13);
    [/quote]

That is valid C++. It defines an integer named "a" and initializes it with the value 13. It follows the same syntax as defining an object and passing one argument to the class's constructor.