LCD Keypad Shield (HCARDU0014)

Post Reply
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

LCD Keypad Shield (HCARDU0014)

Post by admin » Mon Aug 20, 2012 4:46 pm

Image



Image

This shield (HCARDU0014) is designed for 5V Arduino boards that use the standard Arduino header layout such as the Uno, Leonardo, Mega, etc. It is compatible with the standard Arduino LiquidCrystal library which is built into the Arduino development environment (see our example sketches for correct configuration). The shield includes a 16 character by 2 line LCD display with exceptionally clear white text on a blue backlit background. Contrast can be adjusted by means of a multi-turn potentiometer. Six miniature push buttons (SELECT, LEFT, RIGHT, UP, DOWN & RST) provide a user input and only require one input pin to monitored their state. Additional interfaces include an ICSP header which can also double as an SPI interface and pads are provided to allow extra optional headers to be added.

Please note: This shield is designed for 5V Arduino boards such as the Uno, Leonardo, Mega, etc. It is not compatible with 3V Arduino boards.
Due to the way the backlight circuit works do not manually configure digital pin 10 as an high output when this shield is connected.


-
This is a 16x2 LCD Keypad module for ARDUINO Uno/Mega
- Blue Backlight with white text
- Uses standard 4 Bit Arduino LCD Library


Item: LCD Keypad Shield for Arduino Duemilanove & LCD 1602
Dimensions: 3.15 in x 2.28 in x 0.51 in (8.0 cm x 5.8 cm x 1.3 cm)

Order Yours Here



ARD_LCD_HCARDU0014_Hello_World_Example.pde

Code: Select all

 
/* FILE:    ARD_LCD_HCARDU0014_Hello_World_Example.pde
   DATE:    02/07/12
   VERSION: 0.1

This is a simple example of how to use the HobbyComponents Arduino LCD shield
(HCARDU0014). The shield will work with the standard Arduino LiquidCrystal library. 
This code also demonstrates the correct pinnout for the LCD. When you run this
program you should see "HELLO WORLD!" appear on the first line of the display. 

LCD Backlight considerations

By default the LiquidCrystal library does not attempt to control the backlight
and therefore the backlight will default to being permanently on. If you do not 
need to change the state of the backlight you can ignore the following information:

When overriding the state of the backlight via DIO10 from your own code, you must 
drive the pin in one of two modes:

Backlight   DIO10
OFF          OUTPUT/LOW
ON            INPUT

DO NOT configure DIO to be and OUTPUT/HIGH as this can cause excessive current 
to be drawn from DIO10.

You may copy, alter and reuse this code in any way you like but please leave 
reference to HobbyComponents.com in your comments if you redistribute this code.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER 
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES, 
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY 
REASON WHATSOEVER. */


/* Include the standard LiquidCrystal library */
#include <LiquidCrystal.h>


/* DIO pin definitions */
#define LCD_DATA4 4         /* LCD data DIO pin 4 */
#define LCD_DATA5 5         /* LCD data DIO pin 5 */
#define LCD_DATA6 6         /* LCD data DIO pin 6 */
#define LCD_DATA7 7         /* LCD data DIO pin 7 */
#define LCD_RESET 8         /* LCD Reset DIO pin */
#define LCD_ENABLE 9        /* LCD Enable DIO pin */
#define LCD_BACKLIGHT 10    /* LCD backlight DIO pin */


/* Initialise the LiquidCrystal library with the correct DIO pins */
LiquidCrystal lcd(LCD_RESET, LCD_ENABLE, LCD_DATA4, LCD_DATA5, LCD_DATA6, LCD_DATA7);


void setup() 
{
  /* Set the correct display size (16 character, 2 line display) */
  lcd.begin(16, 2);  
}

/* Main program loop */
void loop() 
{
  /* Put the LCD cursor on the first row an print the HELLO WORLD message */
  lcd.setCursor(0,0); 
  lcd.print("HELLO WORLD !");
}
ARD_LCD_HCARDU014_Buttons_Example.pde

Code: Select all

/* FILE:    ARD_LCD_HCARDU014_Buttons_Example.pde
   DATE:    02/07/12
   VERSION: 0.1

 This is a simple example of how to use the buttons included on the 
 HobbyComponents Arduino LCD shield (HCARDU0014). The shield will work 
 with the standard Arduino LiquidCrystal library.
 
 The buttons when pressed apply different offset voltages to the
 Arduino ADC0. Reading the ADC will give an ADC code in the following 
 range depending on which button has been pressed:

     Between 0 & 49 = RIGHT button pressed.
     Between 50 & 194 = UP button pressed.
     Between 195 & 379 = DOWN button pressed.
     Between 380 & 555 = LEFT button pressed.
     Between 555 & 789 = SELECT button pressed.
  
     Above and ADC code of 790, assume no button has been pressed.
  
LCD Backlight considerations

By default the LiquidCrystal library does not attempt to control the backlight
and therefore the backlight will default to being permanently on. If you do not 
need to change the state of the backlight you can ignore the following information:

When overriding the state of the backlight via DIO10 from your own code, you must 
drive the pin in one of two modes:

Backlight	DIO10
OFF		OUTPUT/LOW
ON		INPUT

DO NOT configure DIO to be and OUTPUT/HIGH as this can cause excessive current 
to be drawn from DIO10.

You may copy, alter and reuse this code in any way you like but please leave 
reference to HobbyComponents.com in your comments if you redistribute this code.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER 
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES, 
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY 
REASON WHATSOEVER.

*/



/* Include the standard LiquidCrystal library */
#include <LiquidCrystal.h>


/* DIO pin definitions */
#define LCD_DATA4 4         /* LCD data DIO pin 4 */
#define LCD_DATA5 5         /* LCD data DIO pin 5 */
#define LCD_DATA6 6         /* LCD data DIO pin 6 */
#define LCD_DATA7 7         /* LCD data DIO pin 7 */
#define LCD_RESET 8         /* LCD Reset DIO pin */
#define LCD_ENABLE 9        /* LCD Enable DIO pin */
#define LCD_BACKLIGHT 10    /*LCD backlight DIO pin */


/* Definitions for current button state */
typedef enum
{
  E_LCD_BTN_RIGHT,          /* LCD RIGHT button pressed */
  E_LCD_BTN_UP,             /* LCD UP button pressed */
  E_LCD_BTN_DOWN,           /* LCD DOWN button pressed */
  E_LCD_BTN_LEFT,           /* LCD LEFT button pressed */
  E_LCD_BTN_SELECT,         /* LCD SELECT button pressed */
  E_LCD_BTN_NONE,           /* LCD NONE button pressed */
} 
teButtonState;       


/* Initiliase the LiquidCrystal library with the correct DIO pins */
LiquidCrystal lcd(LCD_RESET, LCD_ENABLE, LCD_DATA4, LCD_DATA5, LCD_DATA6, LCD_DATA7);


void setup() {

  /* Set the correct display size (16 character, 2 line display) */
  lcd.begin(16, 2);  
}


/* Main program loop */
void loop() 
{

  /* Put the LCD cursor on the first row and prompt the user to press a button */
  lcd.setCursor(0,0); 
  lcd.print("Press a button...");

  /* Keep checking for a button press */
  while (1)
  {
    /* Put the LCD cursor on the second row */
    lcd.setCursor(0,1); 

    /* Get the current state of the LCD buttons */
    switch(iGetLCDButtonState())
    {
      /* If the RIGHT button has been pressed then display this on the LCD */
    case E_LCD_BTN_RIGHT:
      lcd.print("RIGHT ");
      break;

      /* If the LEFT button has been pressed then display this on the LCD */
    case E_LCD_BTN_LEFT:
      lcd.print("LEFT   ");
      break;

      /* If the UP button has been pressed then display this on the LCD */
    case E_LCD_BTN_UP:
      lcd.print("UP    ");
      break;

      /* If the DOWN button has been pressed then display this on the LCD */
    case E_LCD_BTN_DOWN:
      lcd.print("DOWN  ");
      break;

      /* If the SELECT button has been pressed then display this on the LCD */
    case E_LCD_BTN_SELECT:
      lcd.print("SELECT");
      break;

      /* If no button has been pressed then display NONE on the LCD */
    case E_LCD_BTN_NONE:
      lcd.print("NONE  ");
      break;
    }
  }
}

/* Read the current state of the LCD buttons using the ADC */
int iGetLCDButtonState()
{
  int iADC_Value;
  int iADC_Button_State = E_LCD_BTN_NONE;

  iADC_Value = analogRead(0);      /* Read the ADC */


  /* If ADC reads above 1000 then assume no buttons have been pressed */
  if (iADC_Value > 1000) 
  {
    iADC_Button_State = E_LCD_BTN_NONE;
  } 
  else /* If it was below 1000 then a button is pressed... */
  {

    /* If ADC reads between 0 & 49, then the RIGHT button has been pressed */
    if (iADC_Value < 50)             
    {
      iADC_Button_State = E_LCD_BTN_RIGHT; 
    }
    else
    {
      /* If ADC reads between 50 & 194, then the UP button has been pressed */
      if (iADC_Value < 195)
      {      
        iADC_Button_State = E_LCD_BTN_UP;      
      }
      else
      {
        /* If ADC reads between 195 & 379, then the DOWN button has been pressed */
        if (iADC_Value < 380) 
        { 
          iADC_Button_State = E_LCD_BTN_DOWN;
        }
        else
        {
          /* If ADC reads between 380 & 555, then the LEFT button has been pressed */
          if (iADC_Value < 555)  
          {
            iADC_Button_State = E_LCD_BTN_LEFT;
          }
          else
          {
            /* If ADC reads between 555 & 789, then the SELECT button has been pressed */
            if (iADC_Value < 790)  
              iADC_Button_State = E_LCD_BTN_SELECT;  
          }
        }
      }
    }
  }
  return iADC_Button_State;
}
Schematic:
LCDKeypad_Shield_SCH_HCARDU0014.pdf
You do not have the required permissions to view the files attached to this post.

ckuehnel
Posts: 1
Joined: Thu Oct 03, 2013 4:55 pm

Re: LCD Keypad Shield (HCARDU0014)

Post by ckuehnel » Thu Oct 03, 2013 5:50 pm

I tried the hello world example on Arduino Yún without success.
I renamed the *.pde into *.ino.
Are there changes to the library required.
Pinout should be OK regarding to the schematic.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: LCD Keypad Shield (HCARDU0014)

Post by andrew » Fri Oct 04, 2013 9:51 am

Unfortunately we don't currently sell the Yun so we can't confirm if the shield and code will work without modification on that board. We can however confirm that it will work with a Leonardo, which the Yun is very similar to. Is it possible for program the Yun as a Leonardo? This may help to identify if the problem is with the Yun's LiquidCrystal library.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

normski001
Posts: 35
Joined: Thu Dec 12, 2013 7:58 am

Re: LCD Keypad Shield (HCARDU0014)

Post by normski001 » Thu Dec 12, 2013 3:40 pm

can you advise how i connect this to my HCARDU0036 rev 3 mega AT2560-16AU please

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: LCD Keypad Shield (HCARDU0014)

Post by andrew » Thu Dec 12, 2013 7:09 pm

Simply plug the shield into the 4 black header sockets closest to the USB connector and run the example sketch in the first post of this thread.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

normski001
Posts: 35
Joined: Thu Dec 12, 2013 7:58 am

Re: LCD Keypad Shield (HCARDU0014)

Post by normski001 » Thu Dec 12, 2013 7:42 pm

andrew wrote:Simply plug the shield into the 4 black header sockets closest to the USB connector and run the example sketch in the first post of this thread.
:roll: upp's should have looked harder at the top of the lcd board :roll:
thank you again. i take it i am down to pins 2 and 3 pwm unless i can still use pins 9 to 13 outputs and i need to solder pins in the outside holes on the display board, also for the 5v and grnd on the rtc will need to come from the display board does this sound ok

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: LCD Keypad Shield (HCARDU0014)

Post by andrew » Fri Dec 13, 2013 11:03 am

i take it i am down to pins 2 and 3 pwm unless i can still use pins 9 to 13 outputs
When using the keypad shield you will lose digital pins 4 to 9. The others should still be free. Don't forget that you are using a Mega and you have many more digital pins free compared to an Uno which can be used for other functions such as your RTC module.
and i need to solder pins in the outside holes on the display board
If you wish to use the pins covered by the keypad shield then yes you would. If you can I would recomend just using the digital pins not covered but the shield.
also for the 5v and grnd on the rtc will need to come from the display board does this sound ok
Yes the power requirements of the RTC module are very small and so this will not be a problem.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “Arduino Shields”