PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Devices
Interface
Keypad 4x4 Digits to Numbers.c
1
/*
2
Keypad 4x4 Digits to Numbers.c
3
Demonstrates how to build numbers with multiple key presses.
4
*/
5
6
#include "
simpletools.h
"
// Libraries simpletools & keypad
7
#include "
keypad.h
"
8
9
int
rows[4] = {7, 6, 5, 4};
// Row I/O pins (top to bottom)
10
int
cols[4] = {3, 2, 1, 0};
// Column I/O pins (left to right)
11
12
int
values[16] = { 1, 2, 3,
'A'
,
// Values for each key in the 4x4
13
4, 5, 6,
'B'
,
14
7, 8, 9,
'C'
,
15
'*'
, 0,
'#'
,
'D'
};
16
17
int
number = 0;
// Stores number result
18
19
int
main
()
// Main function
20
{
21
keypad_setup
(4, 4, rows, cols, values);
// Setup dimensions, keypad arrays
22
23
print
(
"Type a number, then press #\r"
);
// User prompt
24
25
while
(1)
// Main loop
26
{
27
number =
keypad_getNumber
();
// Get number entered on keypad
28
29
print
(
"\r"
);
// Next line
30
print
(
"You entered %d\r"
, number);
// Display result
31
}
32
}
33
keypad_setup
void keypad_setup(int rowCount, int columnCount, int *rowPinCons, int *columnPinCons, int *buttonValues)
Set up the row and column dimensions, pins, and key values.
Definition:
keypad.c:24
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
keypad_getNumber
int keypad_getNumber(void)
Get a number from the keypad. The number will be retured as soon as a non-numeric key is pressed and ...
Definition:
getNumber.c:18
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
keypad.h
Scans matrix keypad and returns a unique value for each key that is pressed. For an example circuit a...
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17