CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account
You are here: Home / GizmoBlog / MMBasic Language / Input and Output / Keypad Interface

Keypad Interface

A keypad is a simple method of entering data into an MMBasic based system. MMBasic supports either a 4×3 keypad or a 4×4 keypad and the monitoring and decoding of key presses is done in the background. When a key press is detected an interrupt will be issued where the program can deal with it.

To enable the keypad feature you use the command:


KEYPAD var, int, r1, r2, r3, r4, c1, c2, c3, c4


Where var is a variable that will be updated with the key code and int is the label of the interrupt to call when a new key press has been detected. r1, r2, r3 and r4 are the pin numbers used for the four row connections to the keypad.

Note that these must be pulled up to 3.3V by individual 10K resistors (see the diagram above). c1, c2, c3 and c4 are the column connections. c4 is only used with 4×4 keypads and should be omitted if you are using a 4×3 keypad.

Any I/O pins can be used and you do not have to set them up beforehand, the KEYPAD command will automatically do that for you.

The detection and decoding of key presses is done in the background and the program will continue after this command without interruption. When a key press is detected the value of the variable var will be set to the number representing the key (this is the number inside the circles in the diagram above). Then the interrupt will be called.

For example:


1
2
3
4
5
6
7
8
9
Keypad KeyCode, KP_Int, 2, 3, 4, 5, 21, 22, 23     ' 4x3 keyboard
 
DO
  < body of the program >
LOOP
 
KP_Int:   ' a key press has been detected
  PRINT "Key press = " KeyCode
IRETURN


 

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2021 · Generate Pro Theme on Genesis Framework · WordPress · Log in