Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
key_complex.cpp
00001 /* 00002 * Mbed Application program 00003 * 00004 * Copyright (c) 2020 Kenji Arai / JH1PJL 00005 * http://www7b.biglobe.ne.jp/~kenjia/ 00006 * https://os.mbed.com/users/kenjiArai/ 00007 * Created: April 5th, 2020 00008 * Revised: April 13th, 2020 00009 */ 00010 00011 // Pre-selection -------------------------------------------------------------- 00012 #include "select_example.h" 00013 //#define COMPLEX 00014 #ifdef COMPLEX 00015 00016 // Include -------------------------------------------------------------------- 00017 #include "mbed.h" 00018 #include "Keypad.h" 00019 00020 // Definition ----------------------------------------------------------------- 00021 #define A_SW 24 // see key_table[25] = A 00022 #define B_SW 3 // see key_table[3] = B 00023 #define C_SW 8 // see key_table[8] = C 00024 00025 // Object --------------------------------------------------------------------- 00026 DigitalOut my_led(D13); 00027 //DigitalOut my_led(LED1); 00028 DigitalOut led0(A0); 00029 DigitalOut led1(A1); 00030 DigitalOut led2(A2); 00031 Serial pc(USBTX,USBRX); 00032 // X Y Z W V A B C D E OUT(XYZWV), IN(ABCDE) 00033 Keypad key(D11, D10, D9, D8, D7, D6, D5, D4, D3, D2); 00034 00035 // RAM ------------------------------------------------------------------------ 00036 00037 // ROM / Constant data -------------------------------------------------------- 00038 // key_table[0]=? is not used! 00039 // 1 2 3 4 5 00040 const char key_table[] = {NUL, 00041 '*', 'G', 'B', '6', '1', // 1 00042 '/', 'H', 'C', '7', '2', // 2 00043 CR, '-', 'D', '8', '3', // 3 00044 SPC, '+', 'E', '9', '4', // 4 00045 BS, '=', 'F', 'A', '5', // 5 00046 NUL 00047 }; 00048 00049 // Function prototypes -------------------------------------------------------- 00050 00051 //------------------------------------------------------------------------------ 00052 // Control Program 00053 //------------------------------------------------------------------------------ 00054 int main() 00055 { 00056 uint32_t key_num; 00057 uint32_t counter = 0; 00058 00059 pc.printf("Start Key-Pad test 5x5 keys and/or state hold switch\r\n"); 00060 while(true) { 00061 while ((key_num = key.read()) != 0) { 00062 pc.printf("%2u:[%2d] %c\r\n", 00063 counter++, key_num, key_table[key_num]); 00064 } 00065 if (key.read_state(A_SW) == true) { 00066 led0 = 1; 00067 } else { 00068 led0 = 0; 00069 } 00070 if (key.read_state(B_SW) == true) { 00071 led1 = 1; 00072 } else { 00073 led1 = 0; 00074 } 00075 if (key.read_state(C_SW) == true) { 00076 led2 = 1; 00077 } else { 00078 led2 = 0; 00079 } 00080 wait_us(100000); 00081 } 00082 } 00083 00084 #endif // #ifdef COMPLEX
Generated on Wed Jul 13 2022 01:19:28 by
1.7.2