device = 16f628a CONFIG INTRC_OSC_NOCLKOUT, CP_OFF, WDT_OFF, PWRTE_ON, LVP_OFF Delayms 200 ; stabilize all_digital = true PORTB_PULLUPS = TRUE dim temp as byte dim keypad as byte symbol beep = porta.6 symbol par_int = porta.7 ; parallel interrupt output symbol ser_int = porta.1 symbol switch = porta.4 ; microswitch input symbol rs232out = porta.0 ; serial output trisa=%00010000 porta=255 loop: repeat ; wait until a key is pressed temp = inkey until temp<>16 keypad = lookup temp, [138,128,139,255,135,136,137,255,132,133,134,255,129,130,131] ;conversion to 'true' bin-values if switch = 0 then ; read jumper setting porta = keypad ; send true-value to portA pulsout par_int, 100, low ; interrupt pulse 1 ms. else keypad = keypad - 128 pulsout ser_int, 100, low ; interrupt pulse 1 ms. serout rs232out, 16486, [ keypad ] ; send data serial to portA.0. 8 bits, 9600 baud, no parity end if sound beep, [115,9] ; short beep at every keypress + debounce repeat ; wait until key is released temp=inkey until temp = 16 porta = 255 ; send initial value to portA goto loop