Pages: [1]   Go Down
Author Topic: Using HD44780 LCD with Arduino analog pins.  (Read 1205 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
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);
}
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: May 12, 2013, 10:16:37 pm by floresta » Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 63
Posts: 2648
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One thing that I noticed is that you also removed a comment from the code
when you modified it:
Code:
* 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
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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!
« Last Edit: May 12, 2013, 10:38:49 pm by Rosscopico0 » Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 63
Posts: 2648
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Code:
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

Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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)


Quote
You declared them yourself with this line:
Code:
int A0,A1,A2,A3,A4,A5;
That is part of the 'extra code' that he was supposed to remove.

Don
Logged

Pages: [1]   Go Up
Jump to: