I finally found where the problem lies but dont know how to fix it. The led blinks but after 4-5 blinks, with the subroutine , it stops. If I dont put a subroutine it keeps on blinking. here is my program.
thanks
INCLUDE "modedefs.bas"
@ DEVICE PIC16F88 , HS_OSC , WDT_OFF , PWRT_ON , BOD_ON , LVP_OFF , PROTECT_OFF
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
ADCON1 = %00100010 ' Set PORTA analog and RIGHT justify result, ADCON1 = %10000010 for 10 bit
ADCON0 = %10010010
TRISA = %11111111 ' Set PORTA to all input
TRISB = %10000000
input1 var byte
loop:
ADCIN 6, input1
pause 30
if input1 > 255 then
portb.3 =0
else
goto blinker
endif
goto loop
Blinker:
portb.3 =1 ' Turn on LED connected to PORTB.6
Pause 500 ' Delay for .5 seconds
portb.3 =0 ' Turn off LED connected to PORTB.4
Pause 500 ' Delay for .5 seconds
return
end
Bookmarks