Hello,
that is great.
I know nothing about your Keypad and connection with Expander, but I suppose you have the pin PB_5 connected to INT pin of the Expander. The INT pin also must have Pull-up resistor to Vcc, so internal pull-up resistor can be not enough.
You probably use the Bare Metal Mbed OS profile, but letting done all the work in ISR is not a good practice.
volatile bool flag = false;
void trigger(){
if(!flag) flag = true;
}
int main(){
pc.printf("Start\n\r");
data1=data2=0;
event.mode(PullUp);
event.fall(&trigger);
//event.rise(&trigger);
lcd.locate(0,0);
lcd.printf("KEY :%d",data1);
while(1)
{
if(flag){
//printf("triggered!\n");
io.write(0x0f);
data1 = io.read();
io.write(0xf0);
data2 = io.read();
display(data1+data2);
//wait(0.2);
flag = false;
}
}
}
BR, Jan