Hi Tony, Thanks so much for posting the codes. I will try it, and advice the result later. Regards, Paul H. ====================== > I haven't tested this but it should work ok. It's written simply, so you > should be able to follow the code. > > Contestant buttons connected from ground to PortB pins 0 - 3 with > pullups enabled. > Connect LEDs via 1K resistors to portB pins 4 - 7 > > list p=16c84,c=140 ; processor type > > status equ 3h > intcon equ 0bh > trisa equ 85h > trisb equ 86h > option_reg equ 81h > t0if equ 2h > temp equ 0ch > > ; 4MHz clock > ; prescaler set to divide by 32 > ; gives about 8mS delay for mnloop > ; you can change this to suit your requirements > ; > ; ------------- > ; PROGRAM START > ; ------------- > ; > > org 0h > > clrf porta > clrf portb > bsf status,rp0 ; RP 1 > clrf trisa ; all outputs - not used > movlw b'00001111' ; 7 - 5 = LED outputs, 3 - 0 = key inputs > movwf trisb > movlw b'00000100' ; pullups on, prescale 1:32 > movwf option_reg > bcf status,rp0 ; RP0 > > ; maybe put a powerup delay routine here > > mnloop nop ; wait approx 8mS > btfss intcon,t0if > goto mnloop > > bcf intcon,t0if ; reset timer flag > movf portb,w ; read portb > movwf temp ; store result > > rrf temp ; if carry clear, key #1 was pressed > btfc status,carry > goto Check2 > > bsf portb,4 ; contestant 1 > goto Loop > > Check2 rrf temp ; if carry clear, key #2 was pressed > btfsc status,carry > goto Check3 > > bsf portb,5 ; contestant 2 > goto Loop > > Check3 rrf temp ; if carry clear, key #3 was pressed > btfsc status,carry > goto Check4 > > bsf portb,6 ; contestant 3 > goto Loop > > Check4 rrf temp ; if carry clear, key #4 was pressed > btfsc status,carry > goto mnloop ; no keys pressed > > bsf portb,7 ; contestant 4 > > Loop goto Loop ; wait here until power down > > > end > > PS Don't forget to disable the WDT > > -- > Best regards > > Tony > > 'The Engine' - Design your own programmer. > > http://www.picnpoke.com > Email picnpoke@cdi.com.au >