Keypad question (aliasing button names)


dumb question here goes:

i have keypad setup this






code: [select]
[code]

char keys[rows][cols] = {
 {
   '1', '2', '3', 'menu', 'more'
 }
 ,
 {
   '4', '5', '6', 'pesc', 'z'
 }
 ,  
 {
   '7', '8', '9', 'enter', 'f_three)'
 }
 ,
 {
   '*', '0', '#', 'sql', 'ftwo'
 }
 ,
 {
   'fone', 'uppersb', 'lowersb', 'arrowdown', 'arrowup'
 }
};




when using if statement have use last character of button name. example:
code: [select]
if (key == 'e') {   // must use e instead of f_one
     indexaccumulator++;
}


what proper procedure establishing meaningful button names beyond 1-9,#,* etc... , utilize them within code? thanks[/code]


dumb question here goes:

i have keypad setup this
code: [select]


char keys[rows][cols] = {
 {
   '1', '2', '3', 'menu', 'more'
 }
 ,
 {
   '4', '5', '6', 'pesc', 'z'
 }
 ,  
 {
   '7', '8', '9', 'enter', 'f_three)'
 }
 ,
 {
   '*', '0', '#', 'sql', 'ftwo'
 }
 ,
 {
   'fone', 'uppersb', 'lowersb', 'arrowdown', 'arrowup'
 }
};




when using if statement have use last character of button name. example:
code: [select]
if (key == 'e') {   // must use e instead of f_one
     indexaccumulator++;
}


single quotes denote single character. "f_one" string, not single character.

quote
what proper procedure establishing meaningful button names beyond 1-9,#,* etc... , utilize them within code? thanks


constants:

code: [select]

const char f_one =0;
const char menu = 1;
const char more = 2;
...
char keys[rows][cols] = {
 {
   '1', '2', '3', menu, more
 }
...
if (key == f_one)
{
 ...


Arduino Forum > Using Arduino > Programming Questions > Keypad question (aliasing button names)


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support