Controlling LCD with pin limitations

Hey !
I have a JHD 204A LCD at my disposal. Since I have already assembled a datalogger, I’m trying to integrate the LCD into the project to display the data being recorded. However, since many pins are already in use for the sensors and the SD shield, I’m in a rut.
These are the pins which are already in use :-

  • Pin 2
  • Pin 6
  • Pin 10
  • Pin 11
  • Pin 12
  • Pin 13
  • Pin A0
  • Pin A4
  • Pin A5

Since I’m a novice, and from what I’ve gleaned, the LCD requires some of the pins present above, which is not possible at the moment.
So, is it possible to control the LCD with the rest of the pins at my disposal ?

I asked Auntie Google and found the following link:

http://www.digibay.in/20x4-character-lcd-module-green-hd44780-controller-jhd-204

The description says it uses 11 ! pins.

Looks like the 2 row displays I played with.

You can connect it through I2C with the controller shown on the same page, or buy a display with such a controller on the back.

If you are using an Arduino Uno or Nano you will have to re-design your current constellation.
Reason:
You are using pins A4/A5 currently for your today's constellation.

These are on Unos and Nanos the only pins which incorporate the I2C functionality. So you will have to find / assign other available pins for your current setup and free the A4/A5 for being used as I2C pins to connect your LCD via I2C.

If you are using another Arduino (e.g. a Micro), the I2C pins are different (Micro: pins 2 and 3).
Have a look at the pinout schematic of your Arduino and look for the I2C pins.

What is the problem? A regular 16x2 only needs 6 GPIO pins for 4-bit write-only mode. Hard wire RW to 0V.
A Uno has got 22 GPIO pins. You are using 9. Avoid the Serial i.e. 0, 1.
So that still leaves you with 11 available pins.

There is NEVER any point in using an 8-bit mode.
Occasionally you might want a 4-bit read-write mode with 7 pins.

And if you are genuinely using lots of pins for sensors etc, choose an I2C backpack for your LCD. If you are already using the I2C bus, this does not cost you ANY extra pins.

David.

Since I'm a novice, and from what I've gleaned, the LCD requires some of the pins present above, which is not possible at the moment.

This is an unfortunate interpretation of the information in the somewhat sketchy tutorial. In fact any available I/O pin, including the so called 'analog' pins, can be connected to any of the LCD pins. Typically you would assign pins with special functions to devices that require those functions and then use the remaining pins for your LCD.

It is the function of the numbers within the argument of the constructor (the string of numbers in parentheses) to tell the Liquid Crystal library which Arduino pin is connected to which LCD pin.

It would all be much clearer if the perpetrators of the library and the authors of the Tutorial had been more liberal with their use of comments:

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here

Here is how to find that information in the documentation:

Don

It would all be much clearer if the perpetrators of the library and the authors of the Tutorial had been more liberal with their use of comments:

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // put your pin numbers here

Wow ! That changes everything !
So does it mean that I can use any pin for the LCD's functionality ?
Forgive this supposedly asinine question, but do tell me the difference between a 4-bit and 8-bit LCD mode.

So does it mean that I can use any pin for the LCD's functionality ?

Yes.

Forgive this supposedly asinine question, but do tell me the difference between a 4-bit and 8-bit LCD mode.

There's no perceptible difference in performance to the end user and no difference in capabilities.

Programming the 4-bit mode is a little bit more difficult but you don't have to worry since the author of the library did all that.

The 8-bit / 4-bit choice is a holdover from the digital stone age when some microprocessors had an 8-bit data bus and others had a 4-bit data bus and the LCD had to be interfaced directly to that bus.

Bottom line, the only thing the 8-bit mode will do for you is tie up four additional I/O lines.

Don