Shop OBEX P1 Docs P2 Docs Learn Events
Sharing LCD Data pins with Buttons — Parallax Forums

Sharing LCD Data pins with Buttons

JimAvantiJimAvanti Posts: 15
edited 2006-08-09 16:07 in BASIC Stamp
I heard it was possible to share the 4 data pins of a parallel LCD with 4 push buttons to save pins.· Has anyone tried this?

Jim

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-08-07 06:17
    Jim -

    You sure can. Prior to writing to the LCD each time, you set the (particular) pin ports to OUTPUT. After you're done writing to the LCD switch them to INPUT before checking the pushbutton's status. It's just about as simple as that. Just make sure you've set them properly (the direction) before each use.

    The pushuttons should be normally open, so they have no impact on the LCD when they're not in use.

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 8/7/2006 6:31:18 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-08-07 06:25
    I think each of those datapins require a 4k7 or 10k pullup resistor.
    Also, between a datapin and its pushbutton, there should be a 1k resistor.
    If the BS happens to be writing to the LCD, this 1k resistor prevents
    a possible short between BS pin and GND. It also prevents that
    the button corrupts the dataline level when the BS is writing.

    regards peter
  • JimAvantiJimAvanti Posts: 15
    edited 2006-08-09 15:00
    But what would happen if a push button was being pressed at the time data was being written to the LCD.· Wouldn't it mess it up?

    Jim
    Bruce Bates said...
    Jim -

    You sure can. Prior to writing to the LCD each time, you set the (particular) pin ports to OUTPUT. After you're done writing to the LCD switch them to INPUT before checking the pushbutton's status. It's just about as simple as that. Just make sure you've set them properly (the direction) before each use.

    The pushuttons should be normally open, so they have no impact on the LCD when they're not in use.

    Regards,

    Bruce Bates

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-08-09 15:01
    That's why you need the resistors. See my earlier post.
    regards peter
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-08-09 15:36
    Jim -

    Peter's answer is exactly correct, and I always BOW to all the hardware guys around here. I'm just a software guy.

    OTOH, I just can't resist the following, in answer to you question:

    Do you have any of those tiny marshmallows around and some small toothpicks smile.gif

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-08-09 16:07
    Jim,
    Parallax just put its little LCD with 4 buttons on sale for $15. You can download the documentation for that and have both the code and the explanation of how it works.

    Personally, I have be thinking of adding a 5th command [noparse][[/noparse]all four buttons down] as you can squeeze more functions out of using more that one button.

    Another alternative documented by Jon Williams in a Nuts and Volts article on menus is to use a SHIFTout IC to drive the LCD and a SHIFTin IC to drive up to 8 buttons. It seems to me that this really gives you the most free pins and the most buttons.

    If code space is running low, a serial LCD may allow you to have more EEPROM as it takes over the management of LCD initialization and housekeeping. AND, you might run SERIALOUT on a PIN 16 configuration that will use your PIN1

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Sign In or Register to comment.