MCP23008 Keypad Interrupt-On-Change demo
Ron Czapala
Posts: 2,418
This demo uses the Interrupt-On-Change feature of the Microchip MCP23008 I/O Expander chip to interface a 4x4 Matrix Keypad (Parallax #27899) to the Propeller.
See Microchip's Application Note AN1081 at http://ww1.microchip.com/downloads/en/AppNotes/01081a.pdf
MCP23008 datasheet
The Propeller only has to monitor one pin to determine that a key has been pressed.
When a key on the keypad is pressed, the MCP23008 INT pin goes LOW and the propeller scans the rows and columns to determine which key is pressed.
Then it clears the interrupt as the key is released.
It uses James Burrow's i2cobject in the OBEX http://obex.parallax.com/object/26
Here is the output on the Parallax Serial Terminal
See Microchip's Application Note AN1081 at http://ww1.microchip.com/downloads/en/AppNotes/01081a.pdf
MCP23008 datasheet
The Propeller only has to monitor one pin to determine that a key has been pressed.
When a key on the keypad is pressed, the MCP23008 INT pin goes LOW and the propeller scans the rows and columns to determine which key is pressed.
Then it clears the interrupt as the key is released.
It uses James Burrow's i2cobject in the OBEX http://obex.parallax.com/object/26
Here is the output on the Parallax Serial Terminal
Setup
Started
GPPU 00001111
GPIO 11110000
IOCON 00000000
1
2
3
A
4
5
6
B
7
8
9
C
*
0
#
D
┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌────┫ 1 ┣───┫ 2 ┣───┫ 3 ┣───┫ A │ │ └─┳─┘ └─┳─┘ └─┳─┘ └─┳─┘ │ ┌─┻─┐ ┌─┻─┐ ┌─┻─┐ ┌─┻─┐ K │ ┌──┫ 4 ┣───┫ 5 ┣───┫ 6 ┣───┫ B │ E │ │ └─┳─┘ └─┳─┘ └─┳─┘ └─┳─┘ Y │ │ ┌─┻─┐ ┌─┻─┐ ┌─┻─┐ ┌─┻─┐ P │ │ ┌┫ 7 ┣───┫ 8 ┣───┫ 9 ┣───┫ C │ A │ │ │└─┬─┘ └─┬─┘ └─┬─┘ └─┬─┘ D │ │ │┌─┻─┐ ┌─┻─┐ ┌─┻─┐ ┌─┻─┐ │ │ ││ * ┣───┫ 0 ┣─┳─┫ # ┣───┫ D │ │ │ │└─┳─┘ └─┳─┘ │ └─┳─┘ └─┳─┘ │ │ │ │ │ │ └─┐ ┌───┘ │ │ │ │ └───┼───┐ │ │ │ │ │ └───────────┼─┐ │ │ │ │ │ └────────────┐ │ │ │ │ │ │ └────────────┐ │ │ │ │ │ │ └────────────┐ │ │ │ │ │ │ │ 8 7 6 5 4 3 2 1 ┌──────┫ │ │ │ │ │ │ │ ┣──────┼─┫ │ │ │ │ │ │ 10k ┣──────┼─┼─┫ │ │ │ │ │ ┣──────┼─┼─┼─┫ │ │ │ │ ┣──────┐ │ │ │ │ │ │ │ │ │ ┌─┴─┴─┴─┴─┴─┴─┴─┴─┴─┐ ─ GP7 thru GP0 (GP7 thru GP4 are pulled high with 10K resistors) │ │ + │ │ │ │ │ │ MCP23008 │ │ │ │ │ │ - │ │ └─┬─┬─┬─┬─┬─┬─┬─┬─┬─┘ │ S S A A A R I │ │ C D 2 1 0 E N │ │ L A │ │ │ S T │ │ │ │ └─┻─┻─┼───┼─┻────VSS └─┳────┼─┼────┳──┻───┼──────VDD └──┫ ┣──┘ │ 3.3V 4.7k│ │4.7k │ │ │ │ Propeller pinsEDIT: Cleaned up code in this attachment...
Comments
Thanks for sharing!!
Added code to OBEX: http://obex.parallax.com/object/750
I took a little Radio Shack IC PCB board and soldered a socket, header pins, resistors and decoupling capacitor to it.
Not as fancy as your custom PCF8574 boards but it gets the job done