;************************************************ ; written by : John Morton * ; date : 21/09/97 * ; version : 1.0 * ; file saved as : Diamond * ; for PIC508 * ; clock frequency : (internal ) = 4 MHz * ;************************************************ ; PROGRAM FUNCTION : To act like diamond brooch by randomly flashing LEDs list P=16Cxx include "c:\pic\p12c50x.inc" ;============ ; Declarations : OffTimer equ 08 #define Tilt GPIO, 3 org 0 movwf OSCCAL ; calibrates internal oscillator goto Start ;=========== ; Subroutines : Init clrf GPIO ; resets general port movlw b'001000' ; GP0 - 2, 4 : LEDs, GP3 : tilt tris GPIO ; GP5 : not connected movlw b'00000111' ; sets up TMR0 option retlw 0 Timing movfw TMR0 ; has 1/10th of a second passed? btfss STATUS, Z ; goto Timing ; no, so keeps looping incf TMR0 ; yes, stops multiple zero read retlw 0 ; returns ;============= ; Program Start : Start call Init ; sets up inputs and outputs Main call Timing ; waits for 1/10th of a second movlw d'27' ; changes LEDs addwf GPIO ; btfsc Tilt ; has tilt signal been received? clrf OffTimer ; yes, so resets Off Timer decfsz OffTimer ; no goto Main ; clrf GPIO ; turns all LEDs off sleep ; goto Main ; loops back up to Main END