Hi, I need some urgent help with arrays please, the purpose of the program is to check for a key pressed and store it into an empty array. And then print the entered sequence on the LCD after 'A' is pressed.
the program compiles but nothing is being stored in the array or printed.
Once this works, I would like to try and take that stored array and use it as an integer for calculations using the '.' and '-' as math functions(which I am also unclear about)
I'm sure the solution is really simple fix.
they are currently no compilation issues.
Hope someone can help
Code:
#include <Keypad.h>
#include <LiquidCrystal.h> // initialize the library with the numbers of the
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
char lonarray[16];
int i;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'}, //define the cymbols on the buttons of the keypads
{'7','8','9','C'},
{'.','0','-','D'}
};
byte rowPins[ROWS] = {13, 12, 11, 10}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {33, 32, 31, 30}; //connect to the column pinouts of the keypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); //initialize an instance of class NewKeypad
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop()
{
char customKey = customKeypad.getKey();
if (customKey == '0'){ lonarray[i] == '0'; i++;}
if (customKey == '1'){ lonarray[i] == '1'; i++;}
if (customKey == '2'){ lonarray[i] == '2'; i++;}
if (customKey == '3'){ lonarray[i] == '3'; i++;}
if (customKey == '4'){ lonarray[i] == '4'; i++;}
if (customKey == '5'){ lonarray[i] == '5'; i++;}
if (customKey == '6'){ lonarray[i] == '6'; i++;}
if (customKey == '7'){ lonarray[i] == '7'; i++;}
if (customKey == '8'){ lonarray[i] == '8'; i++;}
if (customKey == '9'){ lonarray[i] == '9'; i++;}
if (customKey == '.'){ lonarray[i] == '.'; i++;}
if (customKey == '-'){ lonarray[i] == '-'; i++;}
if (customKey == 'A')
{
//lcd.clear;
lcd.print("nmbrs prsd were:");
lcd.setCursor(0,1);
lcd.print(lonarray);
}
delay(250);
Serial.print(customKey);
}