Going loopy, looping the loop


as part of larger project, i'm trying (and failing) sequentially input 3 variables via 12 button keypad.  

each variable 4 digits long , displayed on lcd , used elsewhere in program.  (keypad , lcd hardware has been tested , working fine 'hello world' examples).

i heading down path before getting stuck , doing search;
code: [select]


// borrowed various sources


void loop() {
  // loop 3 variable inputs:
  (int variable = '1'; variable <= '3'; variable++) {
    // loop 4 digit elements contain:
      (int  = '1'; contentsa <= '4'; contentsa++) {
    char key = keypad.getkey();
    if (key != no_key){

//errrr, where???...

      }
    }
  }




looking snippets, tutorials or examples learn from, searched here posts containing;  

if (key != no_key)  

most posts seem relate entering  password , comparing stored password rather getting , holding variable keypad...

widening search, have seen suggestions similar different questons suggested:

"case" (that in answer multi menu question)

or

an array ... ?

or

"make variables global (declared outside of "loop")"
(that in answer question running 1 loop behind another... think wanting do!)

could nudge me in best direction here, i can see several steps in initial approach on pay grade!  :)

i add debounce if required , press , hold options @ future point if makes difference answer(?)

many thanks

ps
i'm retired mech eng,  never programmed before complete noob @ this...  (i may having problems software project mechanicals thing of beauty!  8-)  )









code: [select]
void loop() {
  // loop 3 variable inputs:
  (int variable = 1; variable <= 3; variable++) { // lose single quotes
    // loop 4 digit elements contain:
      (int  = 1; contentsa <= 4; contentsa++) { // , here
    char key = keypad.getkey();
    if (key != no_key){

//errrr, where???...

      }
    }
  }


single quotes value ascii character, '1' has decimal value 49.
can little clearer want do?
posting snippets of code doesn't help, if goal isn't clear.

you don't keypad is, either.

start simple - try lots of examples, pick them apart , try put them together.

yes, "arrays" , "case statements" may help, need pick basics , have clear goal.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Going loopy, looping the loop


arduino

Comments