Go Down

Topic: [SOLVED] Keypad number input and store (Read 42984 times) previous topic - next topic

Count

I tried PaulS code but '#' buttn is not giving any result. Can anybody help me

Badger1875

#16
Apr 07, 2017, 08:53 am Last Edit: Apr 07, 2017, 09:02 am by Badger1875
You read the post #13?

PaulSĀ“hint with the Serial.print...?


Freddie

rjadkins

Is the #3 code a non-blocking code?

isakshehata

i have the same problem as hici but i cant cnfigure whats wrong i dont know where to put serial.print and how
(My problem is that when I press the # button nothing happens. Everything else works. The numbers are printed on the LCD and the * button clears the LCD but. )
always this message came to me :
conversion from 'int' to 'String' is ambiguous
 i want answer fast please.

#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(53, 51, 49, 47, 45, 43);

const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {38, 40, 42, 44};
byte colPins[COLS] = {46, 48, 50, 52};

String x=0;
String y=0;

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
  pinMode(8,OUTPUT);
 
}
         
 void clearscreen()
 {
  lcd.setCursor(0,0);
  lcd.print("                    ");
 
  lcd.setCursor(0,1);
  lcd.print("                    ");
 }
 

void loop(){
 
  analogWrite(8,100);
 
  x = GetNumber();
  x.toInt();
  Serial.println(x);
  lcd.clear();
 y = GetNumber();
 y.toInt();
 Serial.println(y);
 lcd.clear();
}

String GetNumber()
{
 String num = 0;
char key = keypad.getKey();
while(key!='#')
 {
    switch(key)
      {
        case NO_KEY:
        break;
        case'0': case'1': case'2': case'3': case'4': 
        case'5': case'6': case'7': case'8': case'9': 
        lcd.print(key);
        num =(key-'0');
        break;
        case'#':
        return num;
        case'*':
        num=0;
        clearscreen();
        break;
      }
    key = keypad.getKey();
 }
 return num;
 } 

sindhuja

hello frnds.... i have a problem something like this.. i need to enter a phone number using keypad and store it to send sms alerts through gsm module.. i have the code for entering one phone number and can able to read and store that number. but the problem is i need to enter 3 r 4 phone numbers... but am not getting this.. plz..hlp me.. am giving my code below...

ShevyHDTek

Sindhuja, Have you tried placing that code in a for loop or a while loop?

Paul_KD7HB

I really dislike forum hijackers!!!!

tiger45

Sorry. There needs to be a while loop in the GetNumber function. Something like this:
Code: [Select]
int GetNumber()
{
   int num = 0;
   char key = kpd.getKey();
   while(key != '#')
   {
      switch (key)
      {
         case NO_KEY:
            break;

         case '0': case '1': case '2': case '3': case '4':
         case '5': case '6': case '7': case '8': case '9':
            lcd.print(key);
            num = num * 10 + (key - '0');
            break;

         case '*':
            num = 0;
            lcd.clear();
            break;
      }

      key = kpd.getKey();
   }

   return num;
}


Go Up