Hi guys.
Sorry if this is the incorrect place to post.
I'm attempting to make my own basic Source Measure Unit and will be using a typical black 4x4 matrix keypad (I'll attach a picture) for inputting the desired voltage or current. I have been looking around online but cannot find a reliable source, post that isn't a dead end or I'm not searching the correct thing. I am needing to know how I can store the inputted value from the keypad into a float as I will be using values with decimals. For example, I will have it open a menu window when the required action is executed via another button press and that will ask what I want to set the voltage or current to and I will be able to enter say 12.358 volts and once I hit enter it then stores that exact value in the float and that will later get processed by a separate function and the output will be adjusted accordingly. The max value that will be stored in this float will be either 20.000 or 30.000, I'm not sure how much voltage I want to be able to output yet. For current output I'm thinking of only 1.000.
At the moment I have just got the keypad outputting button presses to serial via this code below.
The float named "SetValue" is where i would like to store this value with decimals.
Any help will be greatly appreciated.
#include <Keypad.h>
#define ROW_NUM 4 // four rows
#define COLUMN_NUM 4 // four columns
// Set limiting Values, Values Inputed from keypad
float SetValue = 0;
char keys[ROW_NUM][COLUMN_NUM] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte pin_rows[ROW_NUM] = {19, 18, 17, 5}; // GPIO19, GPIO18, GPIO17, GPIO5 connect to the row pins
byte pin_column[COLUMN_NUM] = {16, 4, 2, 15}; // GPIO16, GPIO4, GPIO2, GPIO15 connect to the column pins
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
void setup() {
Serial.begin(9600);
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.println(key);
}
}