For my project I am using arduino ethernet shield shield, I want to connect a LCD display with my Ethernet shield to display sensor readings(sensors will be connected to the ethernet shield) and display a digital clock on it.But I am really confused about which pins to use as according to arduino tutorials pins 12,11,4 on ethernet shield can't be used and the LCD display uses these pins for connection to arduino. I have gone through many posts on this topic but none of them answers my queries.Any help would be appreciated.
vishrut_pandey:
For my project I am using arduino ethernet shield shield, I want to connect a LCD display with my Ethernet shield to display sensor readings(sensors will be connected to the ethernet shield) and display a digital clock on it.But I am really confused about which pins to use as according to arduino tutorials pins 12,11,4 on ethernet shield can't be used and the LCD display uses these pins for connection to arduino. I have gone through many posts on this topic but none of them answers my queries.Any help would be appreciated.
For normal LCD, you need at least 6 pin, you iterate them by this:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- 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
they have to be in this order. meaning, RS is always the first one.
for I2S LCD, you just need to connect the 2 pins to your arduino, and you need to know the I2S address of your LCD. For your project, I high recommend I2S LCD, namely only 2 pins are required. you don't even need a shield.
If you are using a bare LCD display, you can use any pins you like so long as you nominate them properly.
For instance, in the standard Hello World programme, with
- LCD RS pin to digital pin 12
- LCD Enable pin to digital pin 11
- LCD D5 pin to digital pin 4
and the line
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
You could put RS on 8, Enable on 9 and D5 onto 6, and change the line to
LiquidCrystal lcd(8, 9, 5, 6, 3, 2);
If you are using an LCD shield, similar moves are required. I had to clip pin 4, put a jumper therefrom across to A2, and use
LiquidCrystal lcd(8,9,A2,5,6,7);
instead but I was lucky in only having to make one jumper.
This is the advantage of having the pin call in the programme, rather than having to find and edit it in the library.
I think that Hello World example is moronic. It works as is, but just serves to spook newbies later.
For my project I am using arduino ethernet shield shield ...
.But I am really confused about which pins to use as according to arduino tutorials ...
You are only getting generalized answers because you have not specified exactly which ethernet shield you are using and exactly which arduino tutorial is confusing you. (Most of them are confusing, to put it mildly).
The LiquidCrystal library allows you to use any available I/O pin to drive any of the six LCD data and control lines. You specify which ones you used in the 'constructor'.
//LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // put your pin numbers here
Your ethernet shield is hard-wired to use specific Arduino pins. You must determine which ones those are and then avoid those when choosing I/O pins for the LCD.
If you are using a standalone LCD module this is no problem but if you are using an LCD shield it may be hard-wired to use some of the same pins as your hard-wired ethernet shield. In this second case you would have to do some reworking of one of the shields as mentioned by Nick.
You might also have a similar problem with any of the various serial LCD adapters since they frequently require the use of specific I/O pins.
Don
I am using this ethernet shield: http://arduino.cc/en/Main/ArduinoEthernetShield
And I am confused by the pins on LCD which are to be used as given in this tutotrial: http://arduino.cc/en/Tutorial/LiquidCrystal
The shield and display are nothing out of the ordinary. What you might not understand is that the shield only uses a few pins, most just pass through for use by other shields etc., and that should be evident on examination. That Ethernet shield uses the SPI bus, pins 10,11,12,13 and pin 4 for SD select, just like they all do. You only need to wire the display avoiding these pins and change the line in the constructor to something like
LiquidCrystal lcd(8, 9, 5, 6, 3, 2);
as mentioned before. Also as mentioned before, the tutorial is dumb - but easily fixed. There are conventions in this game... One of them is that you never use pin 4 for anything but selecting the SD because that is where it usually goes, and using it for anything else is something you will probably regret later. Why Mellis & Igoe haven't worked that out is beyond me, and you are suffering for it. Similarly, putting a non-SPI device on the SPI bus, pins 11,12, can't be a good idea and just leads to confusion, but don't ask why they did it.
Using the shield and LCD together is comman practice, and you should not have a problem.
Thanks
what actual LCD make are you using as i would like to do this too
I still have to buy the LCD.As soon as I get things working I will post it .Stay tuned.........