Let's Make Robots!

Connect Arduino to LCD with only 2 pins

Free up to 5 pins.

Shift registers has been mention again and again to free pins for both input and output. This is just another example. I need a LCD display, some buttons, sd card and two extra pins for softSerial communication. I received my LCD and connected it according to the LiquidCrystal reference at Arduino.cc. 7 wires! Where should I put every ting else? I had previously used shift registers when I played with PICAXE years ago. So I started googling for such a solution. And this came up: http://code.google.com/p/arduinoshiftreglcd/ Only a 10K resistor and a diode, and 5 wires less. Bingo:

And this is not all. You can download the library ShiftRegLCD and use in your Arduino sketches instead of LiquidCrystal with minor changes.

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

An analog pin, a batch of resistors, and you could read 8 switches from one pin. :)

Yes you are right.

If I need more pins I might just do that.

But I can read the state of all buttons. One key can act as a shift or clrl key. Or I could add or replace my buttons with a dipswitsh.

BURN!

I could not see any schematic for your buttons. Are you Charlieplexing them?

No, the buttons are read by another shift register as shown on this page:

http://www.arduino.cc/en/Tutorial/ShiftIn

I just didnt have any CD4021 laying around, so I use a 74HC165.

It's a pittly the Shift Register LCD library does not allow you to link another shift register for the buttons. Then you could have saved some more wires.

That’s a brilliant idea. I could daisy chain 74HC165 and 74HC164. If 74HC164 is first in the chain the Shift Register LCD library maybe wouldn’t notice as it does not expect another register.