Sharing IO ports for Keypad and LCD Display

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have IO pin scarcity. Thinking of sharing IO ports PC0 to PC3 between JHD162A based LCD display data lines and Keypad in Atmega328P-AU. Attached is the schematic (Only outline and not full schematic). I tested using simple code and it worked. But in the long run, will there be any design issues? 

 

Attached is the source code. Debounce is done is crude way and need to update and my only worry is debounce that might create problem. 

 

Code Summary:

PC0 to PC3 are output by default so that LCD display can be used any time.

Whenever keypad need to be canned, these PC0 to PC3 are made input lines (in getKeyStatus function) and key pad is scanned. After keypad scanning, PC0 to PC3 are made outputs again at the end of getKeyStatus().

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't see any reason why your method will not work, however you may want to look at how common LCD/Keypad shields work as well using a single analog pin for the keyboard input.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did not understand your point. Could you please elaborate?

using a single analog pin for the keyboard input

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As long as you don't need to read multi-key press at the same time, using this "voltage divider" method works well and does not need debouncing and only uses one analog input pin.

The full schematic can be found, just search for arduino LCD keypad shield schematic and example arduino library for example of how it works.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

YOu can connect a resistor divider to your keyboard buttons and then connect the divider to an analog input pin and write a routine to determine the button push based on the ADC reading.  Quite simple to implement.

 

I would suggest that you look at an I2C expander backpack - theres plenty on the internet- to connect to the back of your LCD if it is an HD44760 compatible unit.  There are also plenty of libraries available for this setup as well.  This way you use only the two TWI pins on the Arduino and the rest for your keypad.  I had boards of my own made up, but ebay and ADAfruit have them as well.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Early TV remote controls were actually wired to the TV.

 

The buttons switched-in different value resistors, so the TV could tell which button was pressed by measuring the resistance

 

I'm sure it's been discussed here before ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Got it. Thanks for this info and this will help me to look from different angle to save IO pins.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

jgmdesign wrote:
I would suggest that you look at an I2C expander

+1

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

If you are looking at port expanders then isn't it time to simply start looking at an AVR with more pins? The natural "big brother" of 48/88/168/328 range (28 pin) are 164/324/644/1284 (40 pin).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
simply start looking at an AVR with more pins

+10!

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

If you are looking at port expanders then isn't it time to simply start looking at an AVR with more pins? The natural "big brother" of 48/88/168/328 range (28 pin) are 164/324/644/1284 (40 pin).

More real estate to cure something that can be soldered to the back of the screen, and two control lines to the AVR?

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

but, surely, if there's a screen and keypad then real estate can't be in short supply ?

 

cheeky

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

depends on the size of the keypad/display IMO.  A conventional LCD is not that big, and keypads can also be rather small.

 

Whatever, we are pulling the thread off its topic.  The OP asked for some alternate options and they have been provided.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user