Am gasit pe un site o modalitate simpla de conectare a unu lcd din gama 44780 prin 2 sau 3 fire la arduino , cu ajutorul unui 74*LS*164 (app 3 ron) . Mai jos o sa pun materialul brut.
This is a library for using an Arduino with only 2 or 3 wires to HD44780-compatible LCD’s, via shiftregisters.
ShiftRegLCD objectName(Datapin, Clockpin, Enablepin or TWO_WIRE [, Lines [, Font]])
where Lines and Font are optional.
- Enablepin: can be replaced by constant TWO_WIRE, if using only 2 wires.
- Lines: 1 or 2 lines (also 4-line LCD’s must be set as 2).
- Font : 0 or 1, small or big font (8 or 10 pixel tall font, if available).
More details on the Usage page.
The compulsory „Hello world” example using a two-wire connection:
Since I had an old HD44780 LCD display, I wanted to connect it to the Arduino, and still have som extra IO pins to use for other things than the LCD 🙂 I hope this might be useful for others too.
Generating the 8 allowable custom characters are also supported. Examples of usage are included.
As of now this library seem to be very reliable regarding starting/initializing the display (as opposed to the first version, at least on my LCD).
I’m pretty new to the Arduino, but I have dabbled a little in both electronics and C++ before. But not much, this is the first class or library I’ve written for C++. Or very C++ like language.
As of 2009.07.27 there is a change to 2-wire connection, and also a new schematics, since the enable of the enable-puls needed to be at the last bit position. Also, a big thanks go to mircho from the arduino playground forum for pointing out a way of using only two wires! He found it at ScienceProg.com. There should still be the option of using 3 wires as before, if needed (see second schematics).
Some have reported problems in two-wire mode when using an 74*HC*164, probably due to the HC not coping with the quick’n’dirty resistor-diode AND gate. It works nice in three-wire mode when I tested it. For two-wire mode I’d recommend using an 74*LS*164.
This is basically a mix between the „Official” LiquidCrystal library and the improved version from LadyAda. Thanks must go to her for all those functions included, and not least a proper initialization routine (though I changed it slightly, I believe, closer to specs)! This library is only tweaked to work with a shift register and the shiftOut() function. I used 74LS164, since that’s what I had. That’s not a fancy shiftregister (no tristate nor latching, not bidirectional etc.).
There are two ways of using this library and connecting to a „shiftregistered” LCD, with 2 or 3-wires:
- In 2-wire mode, the Enable-pin is not used. The Data-pin is used as Enable, together with the AND’ing from shiftregister bit #7 (the diode and resistor in the schematics form a simple AND gate). This method requires an extra write to the shiftregister with zeros to clear it between each write of the nibble (4 bits) to the LCD. This avoids accidental Enable-signals. IE 4 shiftregister writes total to transfer 1 byte to the LCD. Thus using only 2 pins from the Arduino.
- In 3-wire mode, The Enable-pin goes directly from the Arduino to the LCD. Thus using three pins from the Arduino. No clearing of the shiftregister between writes is neccesary, but since the LCD still operates in 4-bit mode, only a nibble is transferred at a time. IE 2 writes to the shiftregister for 1 byte to the LCD.
The time difference is not significant, although 3-wire method is slightly faster. (The clearing of the shiftregisters in 2-wire mode does not need the delays the LCD needs).
In both cases, the two other pins (data and clock) to the shiftregisters respective inputs. Basically any shiftregister should do. It’s very simple, really.
It’s a bit primitive as there is no reading of the busy flag from the LCD. I was playing with the idea of implementing that while still using the same connections from the Arduino. Now I’m not so sure if I’ll ever implement that.
It seems some have 4-line LCD-displays with (I think) common data pins (D0 – D7), and two enable-pins. There should be no problem making two instances of 3-wire ShiftRegLCD objects with the same data and clock-pins, but with different enable pins, thus using 4 pins on the Arduino for a 4-line LCD.
Original version is licensed under Creative Commons Attribution-ShareAlike 3.0 License. I couldn’t find that one here (except for other contents than code), so I hope GNU GPL v3 is not too far off from that one.
New schematics as of 2009.07.28!
The power connection for the 74LS164 is not shown.
For those using 3 wires, this schematics should work with the same library (Not tested this exact version, but a very similar one).