HI, I am new to PicBasic.
I am trying to use PIC18F458 convert 0-5 v analog input, and show the result to LCD. I post my code below. The LCD part works fine, but it always show number "255" on the LCD, even I did not give any voltage input to PORTA.3
So anyone can help me look at my code, and see what is the problem?
Many thanks!!
Min
My code is:
-------------------------------------
DEFINE OSC 4
W1 VAR WORD
include "modedefs.bas"
PAUSE 1000 'LCD takes a second to start
TRISA = 255 'PORTA all inputs
ADCON1 = 0 'PORTA Analog I/O
ADCON0.7 = 1 'Right justified.
' Initialize USART
TRISC = %10111111 'Set TX (PortC.6) to out, rest in
TXSTA = %00100000 'Enable transmit and asynchronous mode
SEROUT PORTC.6,N9600,["Citrus Counter ",254,2]
PAUSE 1000
SEROUT PORTC.6,N9600,[254,1] ' Clear screen
LOOP1:
ADCIN PORTA.3, W1
SEROUT PORTC.6,N9600,[#W1,13]
GOTO LOOP1
END
--------------------------------------------------
Bookmarks