keypad test for the CORE-1000
Dependencies: mbed
main.cpp
- Committer:
- odb
- Date:
- 2018-03-21
- Revision:
- 6:902b4b31fb35
- Parent:
- 2:b60cb847489c
File content as of revision 6:902b4b31fb35:
#include "mbed.h" DigitalOut clkout(PA_8); DigitalIn keyin(PB_4 ); Serial pc(USBTX, USBRX); int oldkey; int getkey(void) { int cnt; int num = 0; for(cnt = 1; cnt < 17; cnt++) { clkout = 0; if(keyin == 0) num = cnt; clkout = 1; } printf("num = %d \n\r", num); return num; } int main() { pc.baud(115200); while(1) { int newkey = getkey(); printf("key pressed = %d \n\r", newkey); oldkey = newkey; wait(0.2); } }