HOME > > ELECTRONICS MAIN PAGE     Delicious.Com Bookmark this on Delicious    StumbleUpon.Com Recommend to StumbleUpon

In a nutshell...

Simple LCD screen for Arduinos, Teensys, etc.

Plus five input buttons.

This page is a much shorted version of a longer guide to a way to attach an attractive backlit LCD screen with two rows of 16 characters to an Arduino or similar device. December 2014, it costs either $12 or £11. It also offers 5 input buttons which only need one input channel to the Arduino to service them.

Stop Press

If you have one of these devices don't "mess with" the signal on the Arduino's D10 pin until you've read how to use D10 to turn the backlight on and off, which is explained at the bottom of this essay.

I have no connection with Hobbytronics or DFRobot or anyone associated with the shield, other than as a "happy customer" of Hobbytronics (I've never had anything to do with DFRobot.) You can get the module from Hobbytronics or DF Robot sells a very similar device. (To be fair, the device probably originated at DFRobot, but I met it on the Hobbytronics page.)

Right... down to business...

-

You can use the module as a shield in an Uno, Diecimila, Duemilanove or Freeduino, or "independently", with any Arduino, Teensy, etc, in one breadboard, and the LCD/ Keypad module in a second breadboard. It only needs 9 wires between the breadboards. (I sometimes refer to those wires as "jumpers" in what follows.)

You could even use it with other microprocessors, if you find yourself an LCD driver for the board of your choice... it should not be hard. You are looking for a driver operating over 4 data bits.

Don't be fooled by the concise version of the name. The keypad and the Liquid Crystal Display are quite separate features. They just happen to share one PCB. You can use just one or the other, if you wish. The board gives you....

The contrast of the writing on the LCD's screen can be adjusted with a simple multi-turn pot which is on the board.

You of course have to connect the module's ground to the driving microprocessor's ground. You must supply the module with 5v.

Read a manual? That's no fun!

Yes, I know, real geeks don't need manuals, but if you have one of these devices, at least be a little cautious with pin D10 until you have looked into the issues associated with that. (Don't do anything in your software to change its default "pin is for an input to the Arduino" state.)

Another quick "you need this!" bit of information for the "try it now" brigade:

"The board uses different pins to the Arduino example
sketches, so to make the display work, use the
following sequence of pins when starting the library:

LiquidCrystal lcd(8,9,4,5,6,7);"

(I'll come back to using the LCD screen in a little while.)

First steps

-

Start by JUST connecting the board's ground and 5v to the Arduino's ground and 5v. Ground to where you see the black wire in the image to the right; 5v to where you see the red wire. The image on the right is of the module's lower edge. (We'll come to the green wire in a moment.)

The small red LED marked "pwr" should come on. You can see it in the image.

When your module is new, you may need to adjust the character/background contrast adjustment pot. "The pot" (potentiometer) is indicated in the image below.


-

This is the only "adjustment" you can (easily) make to what the display looks like. (Later we will see that you can "hide" all the writing on the display, and get it back again. And we can also turn the display's backlight on and off.)

The module draws 25mA, regardless of how you have the pot set.

The keypad

The circuit used for the 5 buttons making up the keypad is quite clever.

Note: There are SIX buttons on the module. The one marked "RST" is simply wired to your Arduino's "ordinary" reset button.

By the clever circuit I alluded to before... and the fact that the Arduino has built-in ADCs (analog to digital converter circuits), you only need to use one of the Arduino's analog inputs to read all five buttons.

If you use the module as a shield, it will connect the five buttons to the "A0" input.

If you are connecting the module to your Arduino with jumpers, you will need one from module's pin marked "A0". It is the pin with the green wire in the image above, the green wire near the red and black wires. You connect it to the analog input of your choice on your Arduino. I would recommend that you choose to use A0.

-

For the buttons to work, you also need the 5v and ground connections mentioned earlier.

You don't "need" it, but in case you want it, here (to the right) is the circuit used in the module, to connect the 5 buttons to one line.

The following simple little program watches the analog input, and displays the readings from it on the Arduino's serial monitor.

void setup()
{
  Serial.begin(9600);
  Serial.println("Welcome to HTronicsLcdKeypad");
  Serial.println("Visit sheepdogsoftware.co.uk for further useful stuff.");
  delay(1200);// Give reader a chance to see the
     //output on the serial monitor. (This program
     //doesn't use the module's LCD.)
 }

void loop()

{
int iAnReading;
iAnReading=analogRead(0);
Serial.println(iAnReading);
}

Set that running. Open up the serial monitor.

You should see a "river" of numbers rushing down the page. If no key was pressed on my system, the reading was 1020.

Pressing the other buttons... one at a time, by the way... should give you different A0 readings.


The LCD screen

If you are using the board as a shield, of course your life is relatively simple.

If you are connecting the Hobbytronics board to an Arduino with jumpers you connect board to Arduino as indicated on the image. Be careful when counting to where you think a wire is... note (red arrow, upper right) that there is one pin with no associated pad.

(Pay no attention to the markings on the PCB the LCD itself is on. (Marked "ignore" in my image.))

-

You don't need, yet, to connect the green wire to "D10". In fact I would suggest you wait to do that until you've read the material at the bottom about using that input to the LCD/Keypad module.

In addition to the yellow wire connections shown in the image, you need to connect the Hobbytronics board to 5v and ground, as already discussed above.

Right! Hardware ready... on to the (very simple) software...

Once you have the device hooked up, the following is a very basic "Hello World".

The "LiquidCrystal" library is a standard library, included with the basic Arduino development environment, at least it was part of the Arduino development environment version "0017".

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.setCursor(0,0);
  lcd.print("Hello World");
  lcd.setCursor(0,1);
  lcd.print("Hobbytronics");
}

A "blow by blow" explanation of the above is available in the longer version of this introduction to the module.

You can visit the main reference page for the LiquidCrystal library to get an idea of other "verbs" you can use.

The noDisplay() and display() words work with the Hobbytronics board. They don't turn off the backlight, but when the "noDisplay" state is in effect, you have a plain panel of illuminated blue, no writing. (We discuss how to turn the backlight on and off at the bottom of this page.)

There was a slight oddity in the scrollDisplay words... If I started with, say....

Hello World
Hobbytronics

... then after one scrollDisplayLeft(), I had, as you might expect,....

ello World
obbytronics

... and with subsequent calls of scrollDisplayLeft(), more and more of the text was "lost" off the left hand edge. Until the screen was blank... and a few more scrollDisplayLeft()s later, the text reappeared, scrolling onto the display from the right hand edge of the display. And yes, I had done the "lcd.begin(16, 2);" to set things up. The software behaves as if there are some "phantom" character positions "off the edge of the LCD", to the right.

Just one of life's little mysteries to keep us on our toes.

And finally... Using D10

If you are CAREFUL, you can use D10 to turn the display's backlight on and off.

Whatever you do, don't set the Arduino's D10 as an output AND have it trying to be high. It isn't rocket science to avoid this combination, but take care that you do avoid it.

Of course, if your Hobbytronics board isn't "piggybacking" on an Arduino, you need to provide a wire between the D10 pins of the two devices. Remember: Ignore the "D10" in the silkscreen labels on the LCD module, the one connected to the main board of the Hobbytronics module. The D10 pin of the Hobbytronics board where I attached the green wire which is next to some yellow wires in my image of the top edge of the board. (I also used green for the A0 wire, you may remember. That one is near a red and a black wire.)

With that wire in place, or the boards piggybacked...

First, in setup(), do....

digitalWrite(10, LOW);

This only needs to be executed once. And yes, I know, it is a bit odd to be doing it while pin 10 is still set up as an input, but it's okay! Just Do It.

Leave the pin "configured" as an input for as long as you want the LCD backlight on. (It starts out "configured" as an input after every reset of the Arduino.)

To turn the backlight off, execute...

pinMode(10,OUTPUT);

And to turn the backlight back on, execute...

pinMode(10,INPUT);

Read, mark and learn: At no time do anything to change the state (high or low) of pin 10. We leave it set to be low whenever it is an output, and we don't change that, even during the times when D10 we have configured D10 as an input.

This would be the place to say "thank you" to the nice people at Hobbytronics, without whom the above could not be written. They kindly steered me towards some facts which I was having trouble perceiving.

I hope this has been of some use.

If it has, I would be grateful if you Facebook "liked", or GooglePlussed this? (There are buttons for both at the top of the page.) Not just to reward my ego, but also to help others find it. Or mention it in blogs, etc? Please?

A little feedback is always welcome. It would be nice to know someone has read, maybe even benefited from, this, after spending a day creating it...

On the more novice-friendly, longer version of this page, there's a relatively trivial little program at the bottom. No rocket science, but it would save you re-inventing a simple wheel. Turns backlight off until a button is pressed, and then displays a welcome message and the current value returned by the input monitoring the buttons.



   Search this site                 powered by FreeFind
 
Site Map    What's New    Search


Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, Sheepdog Software (tm), download something, and circulate it for me? At least (please) send an 'I liked the parallel port use page, and I'm from (country/ state)' email? (No... I don't do spam.) Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Don't forget to check out the programs for controlling the state of the parallel port at my shareware site. There are two free programs there... one for toggling bits, the other for using the computer as a timer via the parallel port.


Here is how you can contact this page's editor.
Click here to go up to general page about electronics by editor of this page.
Click here to go up to general page about electronic projects by editor of this page.
Why does this page have a script that loads a tiny graphic? I have my web traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try it, check out eXTReMe's site. The Google panels and the search panel are also script based.

Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes. There were two "unknown attributes" in Google+ button code, and two further "wrong" things in the Google Translate code. Sigh.


....... P a g e . . . E n d s .....