di3155.txt ;********************************************************************************* ; ; LISTING 1 - THE DURATION BETWEEN TWO MEASUREMENTS ; ; "Novel idea implements low-cost keyboard," EDN, April 3, 2002, pg 69 ; ;********************************************************************************* /* * Function : LittleKb_Scan with 1 I/O * * Description : scans the Little Keyboard * * Return value : 0 if not any touch is pushed * else a value between 1 and 255 * * Note : by default, KB_IO is an output * and its exit is set to 0 (see Note 1) */ BYTE LittleKb_Scan (void) { BYTE bRet = 0; // beginning … KB_IO = 1; // sets I/O (out) to 1 (see Note 1) Delay_us(55); // waits for 55us (see Note 1) KB_IO_Input(); // KB_IO is an input do { bRet++; // counter ++ if(KB_IO == 0) // checks I/O (input) break; } while (bRet != 0); // the loop lasts 2us KB_IO = 0; // resets I/O to 0 (see Note 1) KB_IO_Output(); // KB_IO is an Output // and discharges C return bRet; // … end }