Hi and welcome.
try the following
Code:' ' Pic Configuration ' ================= ASM IFNDEF PM_USED list w=-207 ; Program Configuration Register 1 cfg1 = _INTRC_IO & _WDT_OFF & _PWRTE_ON & _MCLR_OFF & _BODEN_ON & _LVP_OFF & _CCP1_RB0 cfg2 = _CP_OFF & _CPD_OFF & _WRT_PROTECT_OFF & _DEBUG_OFF __CONFIG _CONFIG1, cfg1 & cfg2 ; Program Configuration Register 2 __CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF list w=+207 ELSE device INTRC_OSC_NOCLKOUT, WDT_OFF, PWRT_ON, MCLR_OFF, BOD_ON, LVP_OFF, CCPMX_OFF device PROTECT_OFF, CPD_OFF, WRT_OFF, DEBUG_OFF device2 FCMEN_OFF, IESO_OFF ENDIF ENDASM OSCCON = %01100000 ' set to 4 MHz clock ' ' Hardware configuration ' ====================== TRISB=0 ' Set all PORTB pins to output TRISA=255 ' Set all PORTA pins to output ANSEL = 0 ' disable adc converters CMCON=7 ' disable analog comparator ' ' Hardware assignment ' =================== ' ' Push buttons ' ------------ ' Push buttons are connected between PIC i/o and gnd ' don't forget to add a pull-up resistor on the i/o too ' ONButton VAR PORTA.0 OFFButton VAR PORTA.1 ' ' Light ' ----- ' LED connect between I/O and gnd... with a resistor in serie ' LIGHT VAR PORTB.0 ' ' Hardware initialisation ' ======================= WHILE OSCCON.2=0 : WEND ' wait 'till internal OSC is stable PORTB=0 ' clear all PORTB i/o START: if ONButton = 0 then light = 1 ' turn the LED on endif if offbutton = 0 then light = 0 ' turn the led off endif GOTO START





Bookmarks