Keypad question (aliasing button names)
dumb question here goes:
i have keypad setup this
when using if statement have use last character of button name. example:
what proper procedure establishing meaningful button names beyond 1-9,#,* etc... , utilize them within code? thanks[/code]
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 thiscode: [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
Post a Comment