Using HD44780 LCD with Arduino analog pins.

Hi everyone,
I am working on a project that has used up almost all of my digital I/O pins. I read in the playground that the Analog Input pins can be used as digital I/O as well.
So I modified the LCD "Hello World" sketch to use the pins Analog0 through to Analog5.
However I am not getting any text on the LCD

I suspect it is something do do with configuring the Analog Pins as Digital Outputs, but I am not knowledgeable enough to know what to do.

Any help would be greatly appreciated

Here is the modified code

/*

  The circuit:
 * LCD RS pin to digital pin A0
 * LCD Enable pin to digital pin A1
 * LCD D4 pin to digital pin A2
 * LCD D5 pin to digital pin A3
 * LCD D6 pin to digital pin A4
 * LCD D7 pin to digital pin A5
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
  
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

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

int A0,A1,A2,A3,A4,A5;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);

void setup() {
  
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(A3, OUTPUT);
  pinMode(A4, OUTPUT);
  pinMode(A5, OUTPUT);
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

You shouldn't need all the extra code that you added to deal with the 'pinMode' since that is handled by the LiquidCrystal library. All you should have needed was the change you already made to the 'LiquidCrystal lcd(); contents.

I believe that

LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);

should have worked, but you could also try

LiquidCrystal lcd(14, 15, 16, 17, 18, 19);

.

I hope you didn't forget to ground LCD pin 5 when you reworked your circuit.

Don

One thing that I noticed is that you also removed a comment from the code
when you modified it:

 * LCD R/W pin to ground

While this has no affect on the actual code,
did you hook up the lcd r/w pin to ground?

--- bill

I believe that

LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);

should have worked, but you could also try

LiquidCrystal lcd(14, 15, 16, 17, 18, 19);

.[/color]

I hope you didn't forget to ground LCD pin 5 when you reworked your circuit.

Don

I removed the pinMode extra code with no change.

Turned out it worked with LiquidCrystal lcd(14, 15, 16, 17, 18, 19);

It didn't like the LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);

Thank you for your help!

A0 to A5 should work.
After going back and looking at your code, I can see an issue.
A0, A1, A2, A3, A4 and A5 are defined by an Arduino system header file in pins_arduino.h
You declared them yourself with this line:

int A0,A1,A2,A3,A4,A5;

I'm not sure how it compiled for you.
Your sample code does not compile for me using Arduino 0.22, 1.0, or 1.04

But by defining those yourself,
they will override the Arduino values. (assuming it compiles)
And since they were not filled in with anything,
they would all default to a value of zero.

Are you sure the code you were using was what you posted,
or that it compiled without any errors?

--- bill

did you hook up the lcd r/w pin to ground?

I wish I had thought of that. Oh, I did, and I got it posted more than a minute before you!
(just pulling your leg, Bill)

You declared them yourself with this line:

int A0,A1,A2,A3,A4,A5;

That is part of the 'extra code' that he was supposed to remove.

Don