Arm Mbed OS support forum

Unable to take data from keypad

Hi all,
I am trying to use a 4x4 keypad to get the input numbers and display them on coolterm .The program I wrote is giving erroneous results as the keypad is not waiting for the input data. My board is NucleoF401RE.

Result is -

Please help me resolve this .
Thanks in advance
Regards
Akanksha

Please try my sample program at here.
You need to change port assign.
Please refer circuit example at here.

Thanks
I want to enter only three digits from the keypad but,when I replace while(true) loop with the forloop, nothing appears on the serial terminal, the program does not work
for(i=0;i<3;i++){

         while(((key_num = key.read()) != 0)) {
        printf("%2u:[%2d] %c\r\n",
                  counter++, key_num, *(key_table + key_num));
        c = *(key_table + key_num);   
        printf("%d",c);
    }

I am not able to figure out my mistake
Please help me resolve this issue.

Regards
Akanksha

Please wait input.

	for ( i = 0; i < 3; i++) {
		while(((key_num = key.read()) == 0)) { // waiting for keypad manipulation
			WAIT_100MS();
		}
        printf("%2u:[%2d] %c\r\n",
            counter++, key_num, *(key_table + key_num));
        c = *(key_table + key_num);   
        printf("%d",c);
	}