keypad test for the CORE-1000

Dependencies:   mbed

main.cpp

Committer:
odb
Date:
2017-02-03
Revision:
4:3f409a9fadf9
Parent:
2:b60cb847489c

File content as of revision 4:3f409a9fadf9:

#include "mbed.h"

DigitalOut clkout(PA_8);
DigitalIn keyin(PB_4 );

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;
    }        
    return num;
}

int main() {
    while(1) {
    int newkey = getkey();
    printf("key pressed = %d \n\r", newkey);
    oldkey = newkey;
    wait(0.2);
    }
}