'**************************************************************** '* Name : UNTITLED.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 04.10.2009 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** DEFINE LCD_DREG PORTB ' LCD Data bits on PORTB DEFINE LCD_DBIT 0 ' PORTB starting addressFigure 5.112 (Continued) DEFINE LCD_RSREG PORTB ' LCD RS bit on PORTB DEFINE LCD_RSBIT 5 ' LCD RS bit address DEFINE LCD_EREG PORTB ' LCD E bit on PORTB DEFINE LCD_EBIT 4 ' LCD E bit address DEFINE LCD_BITS 4 ' LCD in 4-bit mode DEFINE LCD_LINES 1 ' LCD has 1 rows ' ' Define A/D converter parameters ' DEFINE ADC_BITS 8 ' A/D number of bits DEFINE ADC_CLOCK 3 ' Use A/D internal RC clock DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us ' ' Variables ' Res Var Word ' A/D converter result Temp1 Var Byte ' Temperature in degrees C TRISA = 1 ' RA0 (AN0) is input TRISB = 0 ' PORTB is output PAUSE 500 ' Wait 0.5sec for LCD to initialize ' ' Initialize the A/D converter ' ADCON1 = 0 ' Make AN0 to AN4 as analog inputs, ' make reference voltage = VDD ADCON0 = %11000001 ' A/D clock is internal RC, select AN0 ' Turn on A/D converter LCDOUT $FE, 1 ' Clear LCD AGAIN: ' ' Start A/D conversion ' ADCIN 0, Res ' Read Channel 0 data Temp1 = 2 * Res ' Convert to degrees C LCDOUT $FE,2,"TEMP = ",DEC2 Temp1, "C" ' Display decimal part PAUSE 1000 ' Wait 1 second GOTO AGAIN ' Repeat END ' End of program