I want to pass elements of global variable array a1[2] from keypad. help me pls. here is my code:
#include "Keypad.h"
#include <LiquidCrystal.h>
unsigned int a1[2]={1,10};
const byte Rows= 4;
const byte Cols= 3;
char keymap[Rows][Cols]=
{
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rPins[Rows]= {22,23,24,25};
byte cPins[Cols]= {26,27,28};
Keypad kpd= Keypad(makeKeymap(keymap), rPins, cPins, Rows, Cols);
void setup() {
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(1,1);1k
lcd.print("Press # to GO");
lcd.setCursor(0,0);
lcd.print("Enter v1: ");
v1 = GetNumber();
}
void loop()
{
...
}
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);
//Serial.print(key);
num = num * 10 + (key - '0');
break;
case '*':
num = 0;
lcd.clear();
break;
}
key = kpd.getKey();
}
return num;
}