PROGRAM B ;************************************ ; written by : John Morton * ; date : 21/07/97 * ; version : 1.0 * ; file saved as : PushButtonA * ; for PIC16F54 * ; clock frequency : 3.82 MHz * ;************************************ ; PROGRAM FUNCTION : If a push button is pressed an LED is turned on list P=16F54 include "c:\pic\p16f5x.inc" __config _RC_OSC & _WDT_OFF & _CP_OFF ;============ ; Declarations : porta equ 05 portb equ 06 org 1FF goto Start org 0 ;=========== ; Subroutines : Init clrf porta ; resets inputs and outputs clrf portb ; movlw b'0000' ; RA0 : LED, RA1-3 : not connected tris porta movlw b'00000001' ; RB0 : push button, RB1-7 : N/C tris portb retlw 0 ;============= ; Program Start : Start call Init Main btfss portb, 0 ; tests push button, skip if pressed goto LEDOff ; push button isn't pressed so turns ; LED off bsf porta, 0 ; push button is pressed so turns LED on goto Main ; loops back to Main LEDOff bcf porta, 0 ; turns LED off goto Main ; loops back to Main END