Thanks but it was right justified. I've added the code below. Sorry, I've forgotten how to use a code window and can't find the thread instructions.
'* This sample program is supplied courtesy of microEngineering Labs Inc *
'************************************************* ****************************
' PicBasic Pro program to display result of
' 10-bit A/D conversion on LCD
' Connect analog input to channel-0 (RA0)
' Define LCD registers and bits
@ DEVICE HS_OSC
DEFINE OSC 20
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTD
Define LCD_RSBIT 2
Define LCD_EREG PORTE
Define LCD_EBIT 1
define LCD_RWREG PORTD
define LCD_RWBIT 3
' Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
adval var word ' Create adval to store result
duty var word
'************************************************* ***************
'Set up (2) Channel Analog input
TRISD=0
TRISE=0
TRISA = %00000001 ' Set PORTA.0 to input,ALL THE REST OUTPUTS
ADCON1 =%00101110 'Set PORTA analog and right justify result
PORTE.2=0 ' Turn off leds so you can use the lcd display
PORTD.3=0 ' LCD R/W line low (W)
Pause 500 ' Wait .5 second
LCDOUT 254,1
PAUSE 500
'************************************************* *****************
'Set up PWM
PR2=9
TRISC.2=0 'Set CCP1 to Output
CCP1CON=%00001100 'SET CCP1 TO PWM
T2CON=%00000100 'SET TIMER2 TO "ON";PRESCALE=1
duty=5
loop:
ADCIN 0, adval ' Read channel 0 to adval
Lcdout $fe, 1 ' Clear LCD
Lcdout "Value: ", DEC adval/64 ' Display the decimal value
Pause 100 ' Wait .1 second
Goto loop ' Do it forever
End






Bookmarks