Hi Gurus of Picland!
yeeees I know thats quite simple thing for you all and I could find it in the data sheet.....but thats my first time on 16F88 . LCD works of course, its just this ansel adcon thingy....
and i searched in the forum but everyone uses RA inputs for analog. They are used for the lcd so I like to use RB7 which hasnt anything else to do.
I would appreciate Your help.
code:
'************************************************* ***************
'* Name : Ananlog1.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2008 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 23.03.2008 *
'* Version : 1.0 *
'* Notes : 16F88 LCD 2x8 connected as ususal *
'* : Portb.7 analog IN 0-2V *
'************************************************* ***************
Include "modedefs.bas"
CMCON = 7 ' PortA = digital I/O
ANSEL = %00000110 ' Will set RB7 as analog I hope
ADCON0 = %11100001
ADCON1 = %10000010
adval var word 'Create adval to store result
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 uSbut show on LCD Value:3
Define osc 4
loop: ADCIN 7, adval ' Read channel 0 to adval
Lcdout $fe, 1 ' Clear LCD
Lcdout "Value: ", DEC adval ' Display the decimal value
Pause 100 ' Wait .1 second
Goto loop ' Do it forever
End
Bookmarks