This might get you started.
I use this for counting parts passing on a conveyor where the parts hit a mechanical switch.
16F873A is used.
Near the top of your code
setup variables and other stuff thenCode:ON INTERRUPT GOTO MYINT INTCON = %10010000
PS.Code:LOOP: 'DO STUFF GOTO LOOP '############################################# 'PART COUNT '############################################ DISABLE MYINT: IF PORTB.0 = 1 THEN PC = PC + 1 WRITE 3,PC.BYTE0 WRITE 4,PC.BYTE1 READ 3,PCNT.BYTE0 READ 4,PCNT.BYTE1 pause 100 ELSE PC = PC ENDIF INTCON.1 = 0 RESUME ENABLE 'THE ABOVE WILL ALSO DEBOUNCE THE SWITCH '#############################################
What is that in your mouth?





Bookmarks