ldi temp, 0xf0 ;set upper four lines to outputs out DDRA, temp ldi temp, 0x0f ;and turn on pullups on the inputs out PORTA, temp nop ;As before wait for the pin to charge nop nop nop in temp, PINA ;read the low nibble or key, temp ;combine to make key code ldi temp,0xff cp key,temp breq illegal ;At the point the raw key code should have exactly one zero
each in ;the lower and upper nibbles. Any other number of zeros indicates ;either no-button pressed or multiple-button pressed.