Shop OBEX P1 Docs P2 Docs Learn Events
MCP23008 Keypad Interrupt-On-Change demo — Parallax Forums

MCP23008 Keypad Interrupt-On-Change demo

Ron CzapalaRon Czapala Posts: 2,418
edited 2014-04-23 13:19 in Propeller 1
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
Setup
Started
GPPU 00001111
GPIO 11110000
IOCON 00000000
1
2
3
A
4
5
6
B
7
8
9
C
*
0
#
D

MCP23008 keypad.jpg


┌───┐   ┌───┐   ┌───┐   ┌───┐
        ┌────┫ 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 pins     
 
EDIT: Cleaned up code in this attachment...

Comments

Sign In or Register to comment.