# Arduino, Keypad and Decimal number

#### mussa

Joined Jun 10, 2019
45
So I wanted to to write a program that ask you to choose between two choices. One allows you to enter a fixed number and the other directly takes you in to a loop. I'm asking for guidance on how to do that? especially the decimal part sense the keypad has no decimal. I thought of using one of the keys on the keypad as a dot maybe (* as .) i'm not sure if that can work.

C:
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <FMTX.h>

float fm_freq; // FM frequency

const byte ROWS = 4;
const byte COLS = 4;

char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'.', '0', '#', 'D'}
};

byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup() {

lcd.begin(16,2);
lcd.backlight();
}

void loop() {

lcd.setCursor(0, 0);
lcd.print("Press A For Loop Freq");
lcd.setCursor(0, 1);

if (customKey = "A") {

fmtx_init(fm_freq, USA);
//lcd.begin(16, 2);
//lcd.backlight();// Turn on Lcd backlight
//lcd.noBacklight();// Turn off Lcd backlight

lcd.setCursor(0, 1);
lcd.print("FM freq: ");
lcd.setCursor(10, 1);
lcd.print(fm_freq, 1); //print the freq  on the lcd with

} else if (customKey = "B" )
{
//The loop.....
}

}
Mod edit: code tags

Last edited by a moderator:

#### be80be

Joined Jul 5, 2008
2,057
Just change this
Code:
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
To this
Code:
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'.', '0', '#', 'D'}
};

#### mussa

Joined Jun 10, 2019
45
Just change this
Code:
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
To this
Code:
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'.', '0', '#', 'D'}
};
that simple... didn't see that

#### mussa

Joined Jun 10, 2019
45
i know in serial monitor we can use while loop as follow:

Serial.println("Press A for a Loop and B to set your own freq ");
while(Serial.available()==0){ }

#### be80be

Joined Jul 5, 2008
2,057
It works the same
lcd.print("Press A for a Loop and B to set your own freq");

#### be80be

Joined Jul 5, 2008
2,057
To help with this you need to post all details what libraries are you using