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)