Arduino LCD Keypad Shield

18,077

14

15

Intro: Arduino LCD Keypad Shield

Step 1: Library

You will need to install the Keypad library.

Step 2: Code

Here is my modified code from the example code included with the library. I added the function to turn on the LED on digital pin 13 when the select button is pushed and to turn it back off then the select button is released.

Step 3: NOTE:

Do not changed digital pin 10. This pin is used to control the back light of the LCD. If its set to output and high it may damage you LCD shield.

Share

    Recommendations

    • Furniture Contest 2018

      Furniture Contest 2018
    • Tiny Home Contest

      Tiny Home Contest
    • Metalworking Contest

      Metalworking Contest

    15 Discussions

    0
    None
    TaranA3

    Question 6 days ago

    I downloaded your sketch but when I tried to compile it I got the following error messages:

    Arduino: 1.8.6 (Windows 10), Board: "Arduino/Genuino Uno"

    FINA14KITKJE85T:6:1: error: 'DFR_LCD_Keypad' does not name a type

    DFR_LCD_Keypad keypad(A0, &lcd);

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino:7:11: warning: uninitialized const 'KEY_RIGHT' [-fpermissive]

    const int KEY_RIGHT;

    ^

    FINA14KITKJE85T:8:19: error: expected initializer before ':' token

    const int KEY_LEFT:

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino:10:11: warning: uninitialized const 'KEY_DOWN' [-fpermissive]

    const int KEY_DOWN;

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino:11:11: warning: uninitialized const 'KEY_NONE' [-fpermissive]

    const int KEY_NONE;

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino: In function 'void setup()':

    FINA14KITKJE85T:22:11: error: 'led' was not declared in this scope

    pinMode(led, OUTPUT);

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino: In function 'void loop()':

    FINA14KITKJE85T:29:14: error: 'keypad' was not declared in this scope

    last_key = keypad.get_last_key();

    ^

    FINA14KITKJE85T:39:12: error: the value of 'KEY_RIGHT' is not usable in a constant expression

    case KEY_RIGHT:

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino:7:11: note: 'KEY_RIGHT' was not initialized with a constant expression

    const int KEY_RIGHT;

    ^

    FINA14KITKJE85T:39:12: error: the value of 'KEY_RIGHT' is not usable in a constant expression

    case KEY_RIGHT:

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino:7:11: note: 'KEY_RIGHT' was not initialized with a constant expression

    const int KEY_RIGHT;

    ^

    FINA14KITKJE85T:43:12: error: 'KEY_UP' was not declared in this scope

    case KEY_UP:

    ^

    FINA14KITKJE85T:47:12: error: the value of 'KEY_DOWN' is not usable in a constant expression

    case KEY_DOWN:

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino:10:11: note: 'KEY_DOWN' was not initialized with a constant expression

    const int KEY_DOWN;

    ^

    FINA14KITKJE85T:47:12: error: the value of 'KEY_DOWN' is not usable in a constant expression

    case KEY_DOWN:

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino:10:11: note: 'KEY_DOWN' was not initialized with a constant expression

    const int KEY_DOWN;

    ^

    FINA14KITKJE85T:51:12: error: 'KEY_LEFT' was not declared in this scope

    case KEY_LEFT:

    ^

    FINA14KITKJE85T:55:12: error: 'KEY_SELECT' was not declared in this scope

    case KEY_SELECT:

    ^

    FINA14KITKJE85T:61:12: error: the value of 'KEY_NONE' is not usable in a constant expression

    case KEY_NONE:

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino:11:11: note: 'KEY_NONE' was not initialized with a constant expression

    const int KEY_NONE;

    ^

    FINA14KITKJE85T:61:12: error: the value of 'KEY_NONE' is not usable in a constant expression

    case KEY_NONE:

    ^

    C:\Users\taran\Downloads\FINA14KITKJE85T\FINA14KITKJE85T.ino:11:11: note: 'KEY_NONE' was not initialized with a constant expression

    const int KEY_NONE;

    ^

    exit status 1

    'DFR_LCD_Keypad' does not name a type

    Invalid library found in C:\Users\taran\Documents\Arduino\libraries\keypad_values: C:\Users\taran\Documents\Arduino\libraries\keypad_values

    Invalid library found in C:\Users\taran\Documents\Arduino\libraries\Yahzee: C:\Users\taran\Documents\Arduino\libraries\Yahzee

    This report would have more information with

    "Show verbose output during compilation"

    option enabled in File -> Preferences.

    0
    None
    philngai

    5 months ago

    Thanks, your library and example sketch worked perfectly for me!

    1 reply
    0
    None
    christmasbob

    6 months ago

    the range of resistance for the up button was set too low. it is closer to 150 ohms. I fixed it in the DFR_LCD_Keypad.h file.

    .#define DFR_LCD_KEYPAD_KEY_UP_ADC_LOW 120

    #define DFR_LCD_KEYPAD_KEY_UP_ADC_HIGH 160

    works now

    0
    None
    RobM230

    Question 6 months ago on Step 2

    I downloaded your sketch but when I tried to compile it I got the following error messages:

    demo_simple:14: error: 'DFR_LCD_Keypad' does not name a type

    demo_simple.ino: In function 'void loop()':

    demo_simple:30: error: 'keypad' was not declared in this scope

    demo_simple:42: error: 'KEY_RIGHT' was not declared in this scope

    demo_simple:46: error: 'KEY_UP' was not declared in this scope

    demo_simple:50: error: 'KEY_DOWN' was not declared in this scope

    demo_simple:54: error: 'KEY_LEFT' was not declared in this scope

    demo_simple:58: error: 'KEY_SELECT' was not declared in this scope

    demo_simple:62: error: 'KEY_NONE' was not declared in this scope

    I am a newbee with Arduino but am trying to learn C++, but would appreciate any suggestions you might have to fix it. Thanks, Rob

    7 more answers
    0
    None
    robmawe91RobM230

    Answer 6 months ago

    I got the same error when compiling on 1.8.1. I discovered that the Library file was in the wrong file directory on my PC. Once I moved it to the right spot it compiled fine for the Uno. I'm not sure if Arduino changed something with the newer IDE or I messed something up transferring everything to my new computer... I will go ahead and download the newist IDE and see if it will compile for me.

    0
    None
    RobM230robmawe91

    Answer 6 months ago

    Thanks. I'll make sure my files are in the correct place as well. Just very frustrating to copy someone else's code - which works - and find I can't compile it or there are error messages. Again, thanks for your help and interest.

    0
    None
    robmawe91RobM230

    Answer 6 months ago

    Thats the only thing I can think of. I uninstalled the Arduino IDE and deleted all my files, installed the newest IDE and added all my files back to the correct directory. Ran the code and it compiled with out any errors. I know it can be very frustrating, I have found many codes were their is some sort of problem. Most of the time it seems to be with the library's either something is wrong or it can't be found online anymore. Hope you get this working!

    0
    None
    RobM230robmawe91

    Answer 6 months ago

    Great advice! I uninstalled then reinstalled IDE 1.8.5. Had moved all my libraries and renamed the folder. Then downloaded new libraries and made sure I put them in the right (Libraries) folder with proper names. Everything works now and I have a functional LCD shield-RTC-Uno clock! Thanks so much for your help. Regards, R

    0
    None
    robmawe91RobM230

    Answer 6 months ago

    Awesome! Glad you got it working.

    0
    None
    robmawe91RobM230

    Answer 6 months ago

    Did you download and instll the library?

    0
    None
    RobM230robmawe91

    Answer 6 months ago

    I did, or at least I think I did, as they show up in the sketch. I tried in both IDE 1.8.5 (compiling error) and 1.0.5. Here are the screen shots. And thanks for your help!

    Screen Shot 2018-03-22 at 8.04.12 PM.pngScreen Shot 2018-03-22 at 8.06.59 PM.png
    0
    None
    Ramkulov

    10 months ago

    Thanks !

    0
    None
    VictorC13

    11 months ago

    Hi

    Thank you for such great information, I now have a functional LCD. The only issue is that the UP button does not work, could it be that I have a broken LCD shield? I am using a shield made by SainSmart. Thank you again

    Victor

    1 reply
    0
    None
    robmawe91VictorC13

    Reply 11 months ago

    It could be the LCD shield or to code. I'm
    not sure if yours works the same as mine. You can check the shield by
    using a multimeter and check the continuity of the button and then
    follow the traces to the pins and recheck. You should only have
    continuity if the button is pressed. If that checks out it could either
    be a problem with the Arduino GPIO connectors (they ware out over time)
    or could be a problem with the library Pinout. If thats the case you can
    modify it or #define in the sketch.