Driving 16x2 LCD Display & Keeping Uno Pin 2 or 3 Free

Good Evening All,

I have a quick query that is driving me crazy...

I have a 16x2 LCD display (LMB162ABC) that I am driving successfully from my Uno; however I also have a flow sensor (http://www.seeedstudio.com/depot/g12-water-flow-sensor-p-635.html?cPath=144_151) which requires one of the external interrupt pins - both of which are in use by the LCD.

So, is there a way of freeing up one of the interrupt pins while still allowing me to use the LCD display?

Any hints, tips or pointers would be very much appreciated!

Thanks

Dan

Hi, do you have other digital IOs available in your project? You can use any other spare digital IOs to control the LCD. However, you will have to initialise your LCD "variable" differently to reflect your new mapping. Let us know if you have queries as to how to set it up.

If you don't have additional or spare IOs then you should look for an IO extender.

Dan

You probably followed the Arduino Liquid Crystal Tutorial at http://arduino.cc/en/Tutorial/LiquidCrystal when you started tinkering with your LCD module. That tutorial happens to use these Arduino pins:

 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2

And they are implemented with this code:

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

If they had added an additional comment like this:

// initialize the library with the numbers of the interface pins
[color=red]// LiquidCrystal lcd(RS, E, D4, D5, D6, D7);[/color]
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

it would be a little clearer that you can use any available I/O pin, including the 'analog' pins, for any LCD line. All you have to do is make sure that the list in your LiquidCrystal lcd() statement matches the pins that you are using.

This is explained in the documentation, but you have to know where to look. It's here: LiquidCrystal - Arduino Reference

It is also in a similar location under the Arduino installation folder on your computer after you install the IDE.

Don

Excellent, Thanks for that guys!

Using the Analog pins works a treat.

Dan

You could just attach the pins normally attached to pins 2-5 on the arduino to pins 4-7 and setup the program like this:
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
That will free both pin 2 and 3.
I hope this helps.

You could just attach the pins normally attached to pins 2-5 on the arduino to pins 4-7 and setup the program like this: ...

How does that differ from what we told him three weeks ago?

Don

You could just attach the pins normally attached to pins 2-5 on the arduino to pins 4-7

I would recommend not using pins 4 or 7 for an LCD. It's a peculiarity with those two where they supply a voltage during the sketch start before the lcd is initialized. This causes the lcd to hang which prevents your program from running.