# /.,';l\][=-`/.,

Hi. I'm working on a project where I need a membrane keypad to send the linear velocity to both an lcd and stepper motor. I would insert the linear velocity in the membrane keypad, it would show it as I type on the lcd, then convert it into rpm and start the stepper motor. The code allows me to insert rpm and send it to the stepper motor, so I was wondering if I can code it so the keypad allows me to have it in linear velocity with decimals. The conversion from linear velocity to rpm is v/(2 π r). I also want it in mm/s so then you would have to multiply the answer from the above equation by 60. If someone can help me asap that would be great and the code is below.
Thanks

``````#include <LiquidCrystal_I2C.h>

#include <Stepper.h>

#include <LiquidCrystal.h>

const int stepsPerRevolution = 2038;

Stepper myStepper = Stepper(stepsPerRevolution, 23, 25, 27, 29);

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

#include <Keypad.h>

// Constants for row and column sizes
const byte ROWS = 4;
const byte COLS = 4;

// Array to represent keys on keypad
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', '.'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};

// Connections to Arduino
byte rowPins[ROWS] = {39, 41, 43, 45};
byte colPins[COLS] = {47, 49, 51, 53};

// Create keypad object
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

String inputString;
long inputInt;
unsigned long loopCount;
unsigned long startTime;

void setup() {

Serial.begin(9600);
inputString.reserve(10); // maximum number of digit for a number is 10, change if needed
lcd.begin(16, 2);

}

int getKeypadIntegerMulti()
{

int value = 0;                                // the number accumulator
int keyvalue;                                     // the key pressed at current moment
int isnum;
do
{
keyvalue = customKeypad.getKey();                          // input the key
isnum = (keyvalue >= '0' && keyvalue <= '9');         // is it a digit?
if (isnum)
{
lcd.print(keyvalue - '0');
value = value * 10 + keyvalue - '0';               // accumulate the input number
}

} while (isnum || !keyvalue);
return value;

}//getKeypadInteger

void loop() {

lcd.clear();
int val = getKeypadIntegerMulti();
// Clear LCD display and print character
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(val);

delay(1);
myStepper.setSpeed(val);
myStepper.step(stepsPerRevolution);
}`````````

Sorry in the Matrix the ‘.’ is supposed to be ‘A’.

Keep track of how many digits arrived after the decimal point. When done receiving digits, divide the number by 10.0 that number of times.

You will need to modify this part of the code to recognize the decimal key and take appropriate action. I suggest to designate a key as “Enter”, to terminate the input, and “Cancel”, to erase and start over.

``````  do
{
keyvalue = customKeypad.getKey();                          // input the key
isnum = (keyvalue >= '0' && keyvalue <= '9');         // is it a digit?
if (isnum)
{
lcd.print(keyvalue - '0');
value = value * 10 + keyvalue - '0';               // accumulate the input number
}

} while (isnum || !keyvalue);
``````