Jeopardy PIC buzzer

From pauljmac.com Projects
Jump to: navigation, search

Assembly Code

; Header ---------
	list	p=16f84a
	__config	h'3ff1'
	radix	hex
; equates --------
portb	equ	0x06	;inputs
porta	equ	0x05 ;outputs
status	equ	0x03

; Program --------
	org 0x00
start	movlw	0xff
	tris	portb	;port b as inputs
	movlw	0x00
	tris	porta ;port a as outputs
loop	movlw 0xff	
	movwf	portb
	btfsc	portb,6	;probe portb 6 to see if its down
	goto	loop
	goto poll
poll	movlw	0x07
	movwf	porta
probe	btfss	portb,0 ;poll player 1
	goto player1
	btfss	portb,1 ;poll player 2
	goto player2
	btfss	portb,2	;poll player 3
	goto player3
	btfss	portb,3 ;poll player 4
	goto player4
	btfss	portb,4	;poll player 5
	goto player5
	btfss	portb,5	;poll player 6
	goto player6
	goto probe
player1	movlw	0x01
	movwf	porta
	return
player2 movlw	0x02
	movwf	porta
	return
player3	movlw	0x03
	movwf	porta
	goto loop
player4	movlw	0x04
	movwf	porta
	return
player5	movlw	0x05
	movwf	porta
	return
player6	movlw	0x06
	movwf	porta
	return
	end

Notes

Pretty code, yes I realize this. This was my first attempt at using a PIC to actually do something useful. Each contestant got their own input line on the PIC for a total of 6 contestants. An input line was used as a reset button to reset the game. The outputs drove BCD chips to display which contestant buzzed in first.