rduino sketches

Discussion in 'Software and Programming' started by chucketn, Feb 16, 2015.

Help Support HMEM by donating:

  1. Feb 16, 2015 #1

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    I'm in the process of combining snippets of working sketches into a single sketch
    I'm getting an error that 'Keypad' does not name a type.

    Funny thing is I copied the keypad info from a working sketch, that compiles and runs. In the new unfinished sketch the line

    Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);

    compiles in one and fails in the other.

    I copied the following from the working sketch to the new one. It errors on the new one! Help?

    #include <Keypad.h>
    const byte rows = 4;
    const byte cols = 4;
    char keys[rows][cols] = {
    {'1','2','3','B'},
    {'4','5','6','L'},
    {'7','8','9','R'},
    {'*','0','#','E'}
    };
    byte rowPins[rows] = {11,10,9,8};
    byte colPins[cols] = {7,6,5,4};
    Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);

    Chuck
     
  2. Feb 16, 2015 #2

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    Well, I fixed it. don't know how...
    I removed some comments from the top of the new file and it compiled with no errors! Strange, the comments were in the original sketch I was modifying...

    Chuck
     
  3. Feb 16, 2015 #3

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
    I'll bet it was an errant or missing // ; or { }
    Syntax is my biggest stumbling block
    Glad you got it sorted

    Scott
     
  4. Feb 16, 2015 #4

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Sounds like the compiler got confused and could not find the keypad.h file so was a library misconfiguration error. Had that a couple of times myself.
     
  5. Feb 16, 2015 #5

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    A few days ago I saw a result in a Google search that looked interesting, but I got involved in another result. Wouldn't you know, now I can't remember what that link was, or the particular search parameter that brought it up. It had something to do with assigning functions to key presses on a 4x4 matrix keypad, like 'Enter', or 'Back Space'. I would like to add a "Store the # entered' type function for what ever number I entered on the keyboard. Can anyone point me in the right direction? I can usually figure it out from a good example.

    Chuck
     
  6. Feb 16, 2015 #6

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    TorontoBuilder likes this.
  7. Feb 17, 2015 #7

    canadianhorsepower

    canadianhorsepower

    canadianhorsepower

    Well-Known Member HMEM Supporter

    Joined:
    Oct 22, 2011
    Messages:
    1,671
    Likes Received:
    320
    does this help

    http://playground.arduino.cc/Main/KeypadTutorial
    cheers
    Luc
     
  8. Feb 18, 2015 #8

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    Thanks, Luc. You must be a mind reader...
    I have been working on this for days. My software development skills leave a lot to be desired. I get so far and forget to save what I have working.
    So far, I have a simple sketch that reads the 4x4 keypad, and displays on the LCD with the I2c serial module. Now back to figuring out how to get the # of divisions entered and stored, and transfer the stepper movement part of Chuck Fellows' sketch.

    Chuck
     
  9. Feb 21, 2015 #9

    prof65

    prof65

    prof65

    Well-Known Member

    Joined:
    Nov 14, 2008
    Messages:
    82
    Likes Received:
    7
    Hi Chuck,
    sometimes, when you use cut and paste you can include some "invisible" chars (newlines, strange symbols...); the editor doesn't show them but they are here and the compiler generates a syntax error.
    If you completely delete the line and rewrite it by hand, without using cut and paste, that error disappears... :wall:
    I saw this with both Arduino and Dev C++ compiler.

    cheers

    Roberto
     
    chucketn likes this.
  10. Feb 21, 2015 #10

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    That makes a lot of sense, Roberto! I have had better luck installing a new library by extracting or unzipping to a folder, then moving the folder to the library. Thanks for pointing that out.

    Chuck
     

Share This Page