'**************************************************************** '* Name : UNTITLED.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2005 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 9/27/2005 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** ' PicBasic Pro program to display result of ' 10-bit A/D conversion through serial at 9600 baud ' ' Connect analog input to channel-0 (RA0) ' Define ADCIN parameters DEFINE OSC 4 start: Include "modedefs.bas" DEFINE ADC_BITS 10 ' Set number of bits in result DEFINE ADC_CLOCK 3 ' Set clock source (3=rc) DEFINE ADC_SAMPLEUS 10 ' Set sampling time in uS TRISA = %11111111 ' Set PORTA to all input ADCON1 = %10000010 ' Set PORTA analog and right justify result Pause 500 ' Wait .5 second ADCvar VAR WORD ' Create variable to store result main: ADCIN 0, ADCvar ' Read channel 0 to adval serout2 PORTC.6, 16468, [DEC ADCVar, 13, 10] ' print it to serial out, ' with linefeed and carriage return (10, 13) GoTo main ' Do it forever