Hello members,
I recently purchased a FRDM-KL25Z from Newark. After receiving it and messing with examples programs I decided to try to use a 4x4 matrix keypad. The information regarding it was already available from HM Yoong Link: Keypad - Cookbook | mbed . My problem is that to have it display what keys were pressed I would have to press the button on the matrix keypad then hit the reset button for it to display the keys on the screen. Furthermore it only seems to allow one button to output; a second button press will not register or display. I have tried numerous changes to the code and even asked assistance on the mbed Questions but with no avail. After seeking help from mbed IRC, a member have informed me that the LPC1768 used a Internal Pull Down. Which maybe different from the KL25Z but does not have the device to determine it. I've tried to find sources online backing the person's information but with no luck.
Any Assistance and or suggestions would be greatly appreciated.
Some attempts that have been made:
Adding a 10k resistance on the columns pins. Visa Versa
Changing Pin numbers on the program to match KL25Z pin layout
The current program is very similar to the Author's Original since I wanted to test it if it's in working condition prior to integrating it to my program.
Source Code:
#include "mbed.h"
#include "rtos.h"
#include "Keypad.h"
Serial PC(USBTX, USBRX);
RtosTimer *LedTimer;
DigitalOut Led1(LED1);
DigitalOut Led2(LED2);
// Define your own keypad values
char Keytable[] = { '1', '2', '3', 'C', // r0
'4', '5', '6', 'D', // r1
'7', '8', '9', 'E', // r2
'V', '0', 'N', 'F' // r3
};
// c0 c1 c2 c3
int32_t Index = -1;
int State;
uint32_t cbAfterInput(uint32_t index)
{
Index = index;
return 0;
}
void Blink(void const *arg) {
if (State == 1) {
Led1 = 1;
Led2 = 0;
State = 2;
}
else if (State == 2) {
LedTimer->stop();
Led1 = 0;
Led2 = 1;
LedTimer->start(2000); // longer timer alarm
State = 1;
}
}
int main()
{
PC.printf("I am Demo Keypad\r\n");
State = 1;
LedTimer = new RtosTimer(&Blink, osTimerPeriodic, NULL);
LedTimer->start(500); // short timer alarm
// r0 r1 r2 r3 c0 c1 c2 c3
Keypad keypad(PTD4, PTA12, PTA4, PTA5, PTA13, PTD5, PTD0, PTD2, 20);
keypad.attach(&cbAfterInput);
keypad.start(); // energize the columns c0-c3 of the keypad
while (1) {
__wfi();
if (Index > -1) {
PC.printf("Interrupted");
PC.printf("Index:%d => Key:%c\r\n", Index, Keytable[Index]);
Index = -1;
}
}
}
-VivaPenguinos-